派生类的构造顺序是什么~~
dokee 2004-11-20 07:19:17 请看下面的程序,难道对象c要调用2个不同类的构造函数吗,岂不是要创建2次了?
#include <iostream.h>
class Vehicle
{
public:
Vehicle()
{
cout<<"constructing an Vehicle object\n";
}
};
class Car:public Vehicle
{
public:
Car()
{
cout<<"constructing an Car object\n";
}
};
void vehiclefn(Vehicle& s)
{
cout<<"call in vehiclefn\n";
}
void main()
{
Car c; //创建对象
Vehicle d;
vehiclefn(c);
vehiclefn(d);
}