如果我运行这段代码
#include<iostream>
using namespace std;
class Final;
class MakeFinal{
public:
friend class Final;
MakeFinal(){cout<<"makefinal\n";}
};
class Final: public virtual MakeFinal{
public:
Final(){cout<<"Final\n";}
};
class Derived:public Final{
public:
Derived(){cout<<"Derived\n";}
};
int main(){
//Final f;
Derived d;
return 0;
}
输出是:
makefinal 最终派生
但是如果我将 MakeFinal() 构造函数设为私有,编译器会显示错误消息。这种不同的构造函数调用层次结构基于什么?