#include<iostream>
#include<string>
#include<vector>
class SubType{
public:
static std::string clsfield;
std::pair<bool,std::string> field;
SubType(bool b,std::string str):field(std::make_pair(b,str)){};
operator bool(){
std::cout<<"calling operator bool()!\n";
}
std::string *operator ->(){
std::cout<<"calling operator ->()!\n";
return &(this->field.second);
}
std::string& operator *(){
std::cout<<"calling operator *()!\n";
return this->field.second;
}
};
std::string SubType::clsfield="heihei";
int main(int argc,char* argv[]){
SubType obj(2,"3.14");
if(obj); //将调用SubType的operator bool()实例方法
std::cout<<obj->size()<<"\n"; //obj->调用operator ->()实例方法返回一个指针,并且后面跟返回的指针的的方法或字段
std::cout<<*obj<<"\n"; //*obj调用operator *()实例方法