2

いくつかの引数を取るコンストラクターを持つクラスを派生させるにはどうすればよいですか?

//The construction in base class:
BaseClass::BaseClass(int inArgument) :
    m_args (inArgument) // where m_args is a public/protected member of the base class
{

}
//The construction of derived class:
DerivedClass::DerivedClass(int inArgument) :
    m_args (inArgument) // where m_args is a public/protected member of the derived class
{

}

コンパイル後、エラー 1 エラー C2512: 'BaseClass' : 適切なデフォルト コンストラクターがありません

私は初心者のC ++プログラマーです...

4

1 に答える 1

8

引数を基本クラスのコンストラクターに転送するだけです。

DerivedClass::DerivedClass(int inArgument) : BaseClass(inArgument)
//                                         ^^^^^^^^^^^^^^^^^^^^^^^
{
}
于 2013-06-14T17:16:25.450 に答える