有以下程序:#includeiostreamusingnamespacestd;classsample{private:intn;public:sample(){}sample(intm){n=m:}sampleadd(samplesl,samples2){this-n=s1.n+s2.n;return(*this);}voiddisp(){coutn=nendl;}};intmain(){samples1(10),s2(5),s3;s3.add(s1,s2);s3.disp();return0:}程序运行后,输出的结果是( )。A.n=10B.n=5C.n=20D.n=15

有以下程序:

#include<iostream>

usingnamespacestd;

classsample

{

private:

intn;

public:

sample(){}

sample(intm)

{

n=m:

}

sampleadd(samplesl,samples2)

{

this->n=s1.n+s2.n;

return(*this);

}

voiddisp()

{

cout<<"n="<<n<<endl;

}

};

intmain()

{

samples1(10),s2(5),s3;

s3.add(s1,s2);

s3.disp();

return0:

}

程序运行后,输出的结果是( )。

A.n=10

B.n=5

C.n=20

D.n=15


相关考题:

有以下程序:include using namespace std;class sample{private: int n;public: samp 有以下程序: #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(10) ,s2(5),s3; s3.add(s1,s2); s3.disp(); return 0; } 程序运行后,输出的结果是( )。A.n=10B.n=5C.n=20D.n=15

以下程序的执行结果是 ( )。include using namespace std;class sample{private: int 以下程序的执行结果是 ( )。 #include <iostream> using namespace std; class sample { private: int x; public: sample (int A) { x=a; } friend double square(sample s); }; double square(sample s) {A.20B.30C.900D.400

若有以下程序:includeusing namespace std;class sample{private:int n;public:sampl 若有以下程序: #include<iostream> using namespace std; class sample { private: int 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=10B.n=5C.n=15D.n=20

有以下程序:includeusing namespace std;class sample{private:int x;public:sample( 有以下程序: #include<iostream> using namespace std; class sample { private: int x; public: sample(int A) { x=a; friend double square(sample s); }; double square(sample s) { return S.X*S.K; } int main() { saA.20B.30C.900D.400

若有以下程序: include usingnamespace std; class Sample { private: const int n; 若有以下程序:include <iostream>using namespace std;class Sample{private:const int n;public:Sample(int i) :n(i) {)void print(){cout<<"n="<<n<<end1;}};int main(){sample a(10);a.print();return 0;}上述程序运行后的输出结果是【 】。

有以下程序:include using namespace std;class sample{private:int n;public:sample 有以下程序: #include <iostream> using namespace std; class sample { private: int 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<<endl; } }; int main() { sample s (10); s.addvalue(5); s.disp(); return 0; } 程序运行后的输出结果是A.n=10B.n=5C.n=15D.n=20

有以下程序:includeusing namespace std;Class sample{private:int n;public:sample( 有以下程序: #include<iostream> using namespace std; Class sample { private: int n; public: sample(){} sample(int m) { n=m; } sample add(sample s1,samplc s2) { this-->n=s1.n+s2.n; return(*this); } void disp(A.n=10B.n=5C.n=20D.n=15

有以下程序:include using namespace std;class sample{private:intn;public:sample( 有以下程序:#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(10),s2(5),s3; s3.add(s1,s2); s3.disp (); return 0;}程序运行后,输出的结果是A.n=10B.n=5C.n=20D.n=15

以下程序段有()处错误。include using namespaces std;class Sample{private: int n;p 以下程序段有( )处错误。 #include <iostream> using namespaces std; class Sample { private: int n; public: Sample (int i} { n=i; } void setvalue(int i) { n=i; } void display() { cout<<"n="<<n<<end1; } }; int main ( ) { const Sample a(lO); a. setvalue (5)'; a.display(); return 0; }A.1B.2C.3D.4

有以下程序:includeusing namespace std;class sample{private:int n; public: sampl 有以下程序: #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); }A.n=10B.n=5C.n=20D.n=15