读书人

C++编程思维中例子求解析

发布时间: 2012-09-17 12:06:51 作者: rapoo

C++编程思想中例子求解析
#include<iostream.h>
class rcout{
public:
rcout(){cout<<"rcout()"<<endl;}

rcout(rcout&){
cout<<"rcout(rcout&)"<<endl;

}
rcout(int ){cout<<"rcout(int )"<<endl;}
rcout& operator=(const rcout&){
cout<<"rcout::operator=()"<<endl;
return *this;
}
class other{};
operator other()const{
cout<<"rcout::operator other()"<<endl;
return other();
}
~rcout(){cout<<"~rcout()"<<endl;}
};
class derived:public rcout{};
void f(rcout::other){}
void main(){
derived d1;
derived d2=d1;
d1=d2;
f(d1);
}
其中class other{};,operator other()const,void f(rcout::other){}不懂是什么意思

[解决办法]
楼主还是买本C++ primer认真补下基础语法吧。
用户自定义类型转换符。

读书人网 >C++

热点推荐