问题 填空题

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

public:
My Class (int x)n=x;
void SetNum (int n1)n=n1;
private:
int n;

int f()

My Class*ptr=new My Class(45);
【12】

答案

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

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

单项选择题
填空题