hito satou; // hito型オブジェクトの作成
hito *p; // hito型オブジェクトのポインタ
class hito suzuki; // 先頭にclassをつけてもOK
/********** 通常の使い方 **********/
satou.age = 20; // メンバ変数に代入
satou.sinchou = 170; // メンバ変数に代入
satou.taiju = 60; // メンバ変数に代入
satou.show_age(); // メンバ関数呼び出し
satou.show_sinchou(); // メンバ関数呼び出し
satou.show_taiju(); // メンバ関数呼び出し
/********** ポインタ形式の使い方 **********/
p = &satou;
p->age = 30; // メンバ変数に代入
p->sinchou = 180; // メンバ変数に代入
p->taiju = 90; // メンバ変数に代入
p->show_age(); // メンバ関数呼び出し
p->show_sinchou(); // メンバ関数呼び出し
p->show_taiju(); // メンバ関数呼び出し
|