运算符重载问题!
这样重载 = 运算符怎么不正确呢!应该怎么做呀?#include <cstdlib>
#include <iostream>
using namespace std;
class assign
{
public:
const char *a;
assign* operator=(const char*str);
};
assign* assign::operator=(const char*str)
{
this->a = str;
return this;
}
int main(int argc, char *argv[])
{
assign* pobj;
pobj="aaaaaaa";
cout<<"object_1.a is "<<pobj->a<<"\n";
system("PAUSE");
return EXIT_SUCCESS;
}
[[it] 本帖最后由 BlueMouse 于 2008-9-16 13:41 编辑 [/it]]