填空题
对于下面定义的类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);
1、
【正确答案】
1、Ptr->SetNum(50);。
【答案解析】
[解析] 本题考查的是考生使用对象指针调用成员函数的能力,指针调用成员函数应该使用符号“->”。
提交答案
关闭