-2
平台: Windows 7中,VS 2012类覆盖分配(=)
我试图做到这一点
Class x{ //FixedThanks to LihO
Public:
char ms[100];
x(){}
x &operator =(char arry[])
{
//Do some operations on ms & arry
return xs;
}
}
void main()
{
//Problem 1: I cant do this it tells about Pointer issue
x ct = new x(); //wont work (fixed thanks to LihO)
x ct; // will work
// Problem 2: I want to assign char array to my clas object
char aty[40]; // filled with some data
ct = aty;
//then I want to be able to do this
send(ct,....etc);
}
任何帮助非常感谢。
注:我没检查覆盖...等,但没有人会给出一个答案,我的问题 问候
你现在的问题是难以理解的。 “我不能这样做,它讲述的是指针问题”是没有意义的。 “我希望能够做到这一点”不是一个问题。如果你用真实的代码问一个真正的问题,人们可能愿意提供帮助。现在,'main()'返回一个'int',你似乎不明白指针是什么,并且你使用空白会导致流泪,即'x&operator =(char arry [])'。 –
请不要修改您的代码以删除其他人在答案中指出的错误,否则会使它们看起来很疯狂。 –
对不起,我因为我不知道如何以适当的方式更新它。 – nothing