継承の説明を行う。電子情報以外の人もいるので、 便利さがどこまで伝わったか心配。
class Person { private: char name[ 10 ] ; int age ; float weight , height ; public: Person( char s[] , int a , float w , float h ) { strcpy( name , s ) ; age = a ; weight = w , height = h ; } void print() { printf( "%s %d %f %f\n" , name , age , weight , height ) ; } } ; class Child : public Person { public: Person* ptr ; public: Child( char s[] , int a , float w , float h , Person* p ) { : Person( s , a , w , h ) { ptr = p ; } Person& parent() { return *ptr ; } } ; void main() { Person tsaitoh( "t-saitoh" , 41 , 79 , 172 ) ; Child mitsuki( "mitsuki" , 6 , 24 , 122 , &tsaitoh ) ; tsaitoh.print() ; mitsuki.parent().print() ; // 継承を使うと mitsuki.print() ; }