Created
October 23, 2014 12:12
-
-
Save TSKGunGun/2ae1de6b7ce2e4fb320f to your computer and use it in GitHub Desktop.
publicのis-a関係
This file contains 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
class Person{}; | |
class Student : public Person{}; | |
void eat( cost Person& rPerson ); //人が食べる関数(人はみな食べる) | |
void study( const Student& rStudent ); //学生が勉強する関数(学生は勉強する) | |
Person P; | |
Student S; | |
eat( P ); //人は食べる | |
eat( S ); //学生も食べる | |
study( S ); //学生は勉強する | |
study( P ); //人は勉強しない |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment