Skip to content

Instantly share code, notes, and snippets.

@TSKGunGun
Created October 23, 2014 12:12
Show Gist options
  • Save TSKGunGun/2ae1de6b7ce2e4fb320f to your computer and use it in GitHub Desktop.
Save TSKGunGun/2ae1de6b7ce2e4fb320f to your computer and use it in GitHub Desktop.
publicのis-a関係
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