私は、次の基本クラスを持っている:派生クラスからメンバ値を取得するには?
class person{
public:
person();
string name;
int age;
};
私は、次の派生クラスがあります:私はいくつかの設定ファイルから名前を取得student
コンストラクタの実装では
class student : public person
{
student();
int grade;
};
を。
派生クラスの名前をperson
クラスに割り当てるにはどうすればいいですか(デフォルト値)。
私はこの実装が間違っている可能性があることを認識していますが、それは私が今必要なものです。
'this.name = something;'は機能しませんか? – songyuanyao
'学生スタッド; stud.name = name_from_file; '? –