单项选择题

有以下程序:
#include <iostream>
using namespace std;
class sample
private:
iht n;
public:
sample()
sample(int m)

n=m;

void addvalue(int m)

sample s;
s.n=n+m;
*this=s;

void disp()

cout<<"n="<<n<<end1;

;
int main()
sample s(10);
s.addvalue(5);
s.disp();
return 0;
程序运行后的输出结果是

A.n=10
B.n=5
C.n=15
D.n=20
<上一题 目录 下一题>
热门 试题

单项选择题
有以下程序 #include <iostream> using namespace std; class R public: R(int r1,int r2) R1=r1; R2=r2; void print(); void print()const; private: iht R1,R2; ; void R::print() cout<<R1 << , <<R2<<endl; void R::print() const cout<<R1 << , <<R2<<endl; int main() R a(5,4); const R b(20,52); b.print(); return 0; 执行后的输出结果是
A.5,4
B.20,52c) 0,0D) 4,5
单项选择题
有以下程序: #include <iostream> using namespace std; class A public: A(int i,int j) a=i; b=j; void move(int x,int y) a+=x; b+=y; void show() cout<<a<< , <<b<<end1; private: int a,b; ; class B: private A public: B(int i,int j): A(i,j) void fun() move(3,5); void fl () A::show(); ; int main() B d(3,4); d.fun(); d.f1(); return 0; 程序执行后的输出结果是
A.3,4
B.6,8
C.6,9
D.4,3
相关试题
  • 【13】 允许用户为类定义一种模式,使得...
  • 有以下程序: #include <iostream> u...
  • 下面是复数类complex的定义,其中作为友元...
  • 数据库系统中实现各种数据管理功能的核心软...
  • 在下面横线上填上适当的语句,完成程序。 ...