以下程序的执行结果是()。includetemplateclass Sample{T n:public:Sample 以下程序的执行结果是( )。 #include<iostream.h> template<class T> class Sample { T n: public: Sample(T i) {n=i;} void operator++(); void disp(){cout<<"n="<<n<<endl;} }; template<class T> void Sample<T>::operator++() { n+=1; // 不能用n++, 因为double型不能用++ } void main() { Sample<char>s('a'); s++; s.disp(); }A.n=aB.a=0C.n=bD.a=b
以下程序的执行结果是()。includetemplateclass Sample{T n:public:Sample
以下程序的执行结果是( )。 #include<iostream.h> template<class T> class Sample { T n: public: Sample(T i) {n=i;} void operator++(); void disp(){cout<<"n="<<n<<endl;} }; template<class T> void Sample<T>::operator++() { n+=1; // 不能用n++, 因为double型不能用++ } void main() { Sample<char>s('a'); s++; s.disp(); }
A.n=a
B.a=0
C.n=b
D.a=b
相关考题:
以下程序的执行结果是______。 include class Sample { int n; public: Sample() {} 以下程序的执行结果是______。include<iostream.h>class Sample{int n;public:Sample() {}Sample (int i (n=i;)void add (Sample s1,Sample s2){this->n=sl.n+=s2.n;}void disp() {cout<<" n="<< n <<end1:}}void main ()
下列程序的执行结果是()。includeclass Sample{int x,y;public:Sample(){x=y=0;)Sam 下列程序的执行结果是( )。 #include<iostream.h> class Sample { int x,y; public: Sample(){x=y=0;) Sample(int a,int b){x=a;y=b;} ~Sample() { if=(x==y) cout<<“x=y”<<endl; else cout<<“x!=y”<<endl; } void disp() { coutA.x=2,y=2B.x=3,y=3C.x=2,y=3D.x=3,y=2
以下程序的执行结果是______。 inelude class Sample { public: int x; int y; void 以下程序的执行结果是______。inelude<iostream.h>class Sample{public:int x;int y;void disp( ){cout<<"x="<<x<<",y="<<y<<endl;}};void main( ){int Sample::*pc;Sample s;pc=Sample::x;s.*pc=10;pc=Sample::y;s.*pc=20;s.disp( );}
分析以下程序的执行结果【】。includeclass Sample{int x, y;public:Sample() {x=y=0; 分析以下程序的执行结果【 】。include<iostream.h>class Sample{int x, y;public:Sample() {x=y=0; }Sample(int a, int b) { x=a; y=b;}~Sample(){if(x==y)cout<<"x=y"<<end1;elsecout<<"x!=y" <<end1;}void disp(){cout<<"x="<<x<<",y="<<y<<end1;}};void main(){Sample s 1 (2,3);s1.disp();}
以下程序的执行结果是【】。includeincludeclass Sample{ public: int x,y; 以下程序的执行结果是【 】。include<iostream.h>include<stdlib.h>class Sample{public:int x,y;Sample(){x=y=0;}Sample(int a,int b) {x=a;y=b; }void disp(){cout<<"x="<<x<<",y="<<y<<end1;}};void main() {Sample s1(2,3);s1.disp();}
下列程序的运行结果是【 】。includeclass Sample{int a;public: Sample(int aa=0) {a 下列程序的运行结果是【 】。include<iostream, h>class Sample{int a;public:Sample(int aa=0) {a=aa;}~Sample() {cout<<"Sample="<<a<<;}class Derived: public Sample{int b;public:Derived(int aa=0, int bb=0): Sample(aa) {b=bb;}~De rived() {cout <<"Derived="<<b<<'';}void main(){Derived dl (9)}
以下程序的执行结果是【 】。 include class Sample { public: int x: int y; void di 以下程序的执行结果是【 】。include<iostream. h>class Sample{public:int x:int y;void disp(){cout<<"x="<<x<<",y="<<y<<end1;}};void main(){int Sample:: ** pc;Sample s;pc= Sample: :x;s.*pc=10;pc:=Sample: :y;s.*pc=20;s.disp();}
以下程序的执行结果是()。includetemplateclass Sample{ T n;Public: Samp 以下程序的执行结果是( )。 #include<iostream.h> template<class T> class Sample { T n; Public: Sample (T i){n=i;) void operator ++(); void disp() {cout<<"n="<<n<<endl;} }; template<class T> void Sample<T>:: opetatA.n=aB.a=OC.n=bD.a=b
以下程序的执行结果为()。includeClass sample{ int n;public: sample(int i){n=i;} 以下程序的执行结果为( )。 #include<iostream.h> Class sample { int n; public: sample(int i){n=i; } operator ++() { n++; } void display() {cout<<n<<end1; } }; void main() { sample obj(5); obj++;A.5B.6C.7D.8