Last active
August 29, 2015 14:12
-
-
Save karubabu/ff2687bbaeaa57b3bb79 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
using namespace std; | |
class Acls { | |
public: | |
int a; | |
void disp(){ cout << "Acls: a=" << a << endl; } | |
}; | |
class Bcls: public Acls { | |
public: | |
int b; | |
void disp(){ cout << "Bcls: a=" << a << " b=" << b << endl; } | |
}; | |
int main(){ | |
Acls* ap; | |
Bcls bd; | |
bd.a = 10; | |
bd.b = 20; | |
ap = &bd; | |
ap->disp(); | |
return 0; | |
} | |
//実際の出力はAcls: a=10 | |
//本での出力はAcls: a=20 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment