Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- typedef int data;
- class data_provider {
- public:
- virtual data get_data() = 0;
- };
- class specific_data_provider : public data_provider {
- public:
- data get_data() {
- return 7;
- }
- };
- class my_device {
- public:
- data_provider * dp;
- data d;
- my_device (data_provider * adp) {
- dp = adp;
- d = 0;
- }
- void update() {
- d = dp->get_data();
- }
- };
- int
- main() {
- specific_data_provider sdp;
- my_device dev(&sdp);
- dev.update();
- printf("d = %dn", dev.d);
- return 0;
- }
- struct A { int x; };
- struct B : A { int y; };
- struct C { int x, y; };
- struct A { virtual ~A(); };
- struct B : A { ... };
Add Comment
Please, Sign In to add comment