satellite.cpp
1.28 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
#include <iostream>
using namespace std;
struct Task
{
int next_event_time;
void execute(){};
virtual void get_debug(){ cout << "Task" << endl;};
virtual int f(int){};
};
struct Displayed
{
int x;
int y;
int z;
int rotx;
int roty;
int rotz;
virtual void draw(){};
virtual void get_debug(){cout << "Displayed" << endl;};
double f(double){};
};
struct Satellite : public Task, public Displayed
{
double uplink_frequency;
double downlink_frequency;
void transmit();
using Displayed::f;
using Task::f;
virtual void get_debug(){cout << "Satellite" << endl;};
};
struct Test {
int a;
double b;
};
int main()
{
cout << sizeof(Task) << endl;
cout << sizeof(Displayed) << endl;
cout << sizeof(Satellite) << endl;
Satellite s;
Satellite* sptr = &s;
cout << (char*)(&(sptr->next_event_time)) - (char*)sptr << endl;
cout << (char*)(&(sptr->x)) - (char*)sptr << endl;
cout << (char*)(&(sptr->rotz)) - (char*)sptr << endl;
cout << (char*)(&(sptr->uplink_frequency)) - (char*)sptr << endl;
cout << offsetof(Test, b) << endl;
Task* tptr = sptr;
Displayed* dptr = sptr;
cout << sptr << "," << tptr << "," << dptr << endl;
return 1;
tptr -> get_debug();
dptr -> get_debug();
sptr -> get_debug();
sptr -> f(1);
return 0;
}