これは、基本クラスのコンストラクターを呼び出す正当な方法ですか?
基本クラスは次のとおりです
class base_class
{
public:
base_class(int x, int y);
protected:
int a;
int b;
};
base_class::base_class(int x,int y)
{
a=x;
b=y;
}
派生クラスは次のとおりです
class derived_class: public base_class
{
public:
derived_class(int x,int y,int z);
protected:
int c;
};
derived_class:: derived_class(int x,int y,int z):base_class(x,y) /*Edited and included the scope resolution operator*/
{
c=z;
}
派生クラス コンストラクターを定義するこの方法は C++ で有効ですか? はいの場合、基本クラス コンストラクターはどのように呼び出されますか?