单项选择题
有以下程序:
#include <iostream>
using namespace std;
class sample
private:
int n:
public:
sample ()
sample(int m)
n=m;
sample add(sample s1, sample s2)
this->n=s1.n+s2.n;
return (*this);
void disp ()
cout <<"n="<<n<<end1;
;
int main()
sample s1(1)0,s2(5),s3;
s3.add(s1,s2);
s3.disp();
return 0;
程序运行后,输出的结果是
A.n=10
B.n=5
C.n=20
D.n=15
点击查看答案&解析
<上一题
目录
下一题>
热门
试题
单项选择题
有如下程序: #include <iostream.h> using namespace std; class Base protected: int i: public: int j; ; class Derived: public Base int m: public: int n; int main() Derived d: d.i=0; [1] d.J=0; [2] d.m=0; [3] d.n=0: [4] return 0; 其中主函数中有两个赋值语句有错,这两个错误的赋值语句是
A.[1]和[2]
B.[1]和[3]
C.[2]和[3]
D.[2]和[4]
点击查看答案&解析
单项选择题
有以下程序 #include <iostream> int i = 0; void fun( ) static int i = 1; std::cout<<i++<<’,’; std::cout<<i<<’,’; int main() fun(); fun(); return 0; 程序执行后的输出结果是
A.1,2,1,2,
B.1,2,2,3,
C.2,0,3,0,
D.1,0,2,0,
点击查看答案&解析
相关试题
与成员访问表达式p->name等价的表达式是...
有如下程序: #include <iostream> u...
下列函数的功能是判断字符串str是否对称,...
在数据库的概念结构设计中,常用的描述工具...
在下面程序的横线处填上适当的内容,使程序...