gpt4 book ai didi

c++ - 我怎样才能派生一个具有接受一些参数的构造函数的类?

转载 作者:太空狗 更新时间:2023-10-29 23:52:10 25 4
gpt4 key购买 nike

<分区>

我如何派生一个类,该类的构造函数接受一些参数?

//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
{

}

编译后我得到:Error 1 error C2512: 'BaseClass': no appropriate default constructor available

我是一个初学c++程序员...

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com