问题 填空题

对于下面定义的类MyClass,请在函数f()中添加对象成员把n的值修改为50。
Class MyClass

Public:
MyClass(int x)n=x;)
Void SetNum(int nl)n=nl;
private:
int n;

int f()

MyClass*ptr=new MyClass(45);

答案

参考答案:Ptr->SetNum(50);。

解析: 本题考查的是考生使用对象指针调用成员函数的能力,指针调用成员函数应该使用符号“->”。

填空题
填空题