#include <iostream>
using namespace std;
class Base{
private:
int data;
public:
Base(int _data = 1){
cout<<"Base(int _data = 1)"<<endl;
//cout<<"this->"<<this<<endl;
data = _data;
//this->display();
}
Base(const Base& another){
cout<<"Base(const Node& another)"<<endl;
data = another.data;
}
Base& operator=(const Base& another){
cout<<"operator = "<<endl;
data = another.data;
return *this;
}
void display(){
cout<<"display()"<<endl;
}
};
class Drive{
private:
Base base;
public:
Drive(const Base& another){
cout<<"Drive(const Base& another)"<<endl;
//cout<<"another->"<<&another<<endl;
//cout<<"Drive this->"<<this<<endl;
base = another;
}
};
int main()
{
cout << "Hello world!" << endl;
Base tmp(55);
cout<<"-------------"<<endl;
//cout<<"tmp ->"<<&tmp<<endl;
Drive test(tmp);
return 0;
}
上面代码的输出会多出来一个Base(int _data)的调用,所以我想知道的是Drive(const Base& another)函数的具体执行过程???求帮忙解答
潇潇雨雨
ibeautiful
随时随地看视频慕课网APP
相关分类