📜  c++ 基本构造函数 - C++ 代码示例

📅  最后修改于: 2022-03-11 14:44:58.760000             🧑  作者: Mango

代码示例1
class Derived: public Base
{
public:
    double m_cost;
 
    Derived(double cost=0.0, int id=0)
        : Base{ id }, // Call Base(int) constructor with value id!
            m_cost{ cost }
    {
    }
 
    double getCost() const { return m_cost; }
};