65,211
社区成员
发帖
与我相关
我的任务
分享....
.....
.....
class Counter
{
string a;
public:
operator string()
{
return a;
}
};
int _tmain(int argc, _TCHAR* argv[])
{
Counter a;
cout << "退出 请按 A" << std::endl;
while( a != "A" )
{
cout << " 输入你要计算的表达式: ";
cout << "值为: " << a << '\n';
}
system("pause");
return 0;
}
using namespace std;
class Counter
{
string a;
int m;
public:
Counter(string str = "test"):a(str),m(100){}
operator string()
{
return a;
}
operator int(){
return m;
}
};
void xxx(string s){
cout<<s<<endl;
}
int main(){
Counter x;
cout<<x<<endl;
xxx(x);
if (x == 100)cout<<"ok"<<endl;
system("pause");
return 0;
}
using namespace std;
class Counter
{
string a;
public:
Counter(string str = "test"):a(str){}
operator string()
{
return a;
}
};
void xxx(string s){
cout<<s<<endl;
}
int main(){
Counter x;
xxx(x);
if ((string)x == "test")cout<<"ok"<<endl;
system("pause");
return 0;
}
string a = "A";
if( a == "A")
cout << "a";
是不是 你看下就知道。