单项选择题

以于下面定义的类MyClass, 在函数f()中将对象成员n的值修改为50的语句应该是( )。
class MyClass

public:
MyClass (int x)

n=x;

void SetValue(int n1)

n=n1;

private:
int n;
;
int f()

MyClass *ptr = new MyClass(45);
________________;

A.MyClass(50)
B.SetValue (50)
C.ptr->SetValue(50)
D.ptr->n=50
<上一题 目录 下一题>
热门 试题

单项选择题
若有以下程序: #include <iostream> using namespaces std; class A public: A () A (int i) x1=i; void dispa() cout<< xl= <<xl<< , ; private: int x1; ; class B : public A public: B () B (int i):A(i+10) x2=i; void dispb() dispa (); cout << x2= <<x2<<end1; private: int x2; ; int main () B b(2); b.dispb (): return 0; 程序运行后的输出结果是( )。
A.x1=10,x2=2
B.x1=12,x2=10
C.x1=12,x2=2
D.x1=2,x2=2
单项选择题
若有以下程序: #include <iostream> using namespace std; class Base private: int a,b; public: Base(int x, int y) a=x; b=y; void show() cout<<a<< , <<b<<end1; ; class Derive : public Base private: int c, d; public: Derive(int x, int y, int z,int m):Base(x,y) c=z; d=m; void show() cout<<c<< , <<d<<end1; ; int main ( ) Base b(50,50) ,*pb; Derive d(10,20,30,40); pb=&d; pb->show ); return 0;
A.10,20
B.30,40
C.20,30
D.50,50
相关试题
  • 若有以下程序: #include <iostream>...
  • 有如下程序: #include <iostream> u...
  • 如果一个数组中的每个元素都是同一类的对象...
  • 下列程序在构造函数和析构函数中申请和释放...
  • 下面程序的打印结果是 【11】 。 #in...