网友您好, 请在下方输入框内输入要搜索的题目:
题目内容
(请给出正确答案)
对于下面代码,空白处正确的是 class S { public: auto x {3}; auto y {1.1}; auto z { 'a' }; } int main () { S s; ____________________; std::cout << a << "t" << b << "t" << c; return 0; }
A.auto [a, b, c] { s }
B.int a, b, c = s
C.int [ a, b, c ] = {s}
D.auto a {s}, b{s}, c{s}
参考答案和解析
Score没有带一个参数的构造方法
更多 “对于下面代码,空白处正确的是 class S { public: auto x {3}; auto y {1.1}; auto z { 'a' }; } int main () { S s; ____________________; std::cout << a << "t" << b << "t" << c; return 0; }A.auto [a, b, c] { s }B.int a, b, c = sC.int [ a, b, c ] = {s}D.auto a {s}, b{s}, c{s}” 相关考题
考题
有如下程序:#includeusing namespace std;class Complex{double re, im;public:Complex(double r, double i):re(r), im(i){}double real() const{return re;}double image() const{return im;}Complex operator +=(Complex a){re += a.re;im += a.im;return *this;}};ostream operator(ostream s,const Complex z){return s'('}int main(){Complex x(1, -2), y(2, 3);cout(x += y)return 0;}执行这个程序的输出结果是A . (1, -2)B . (2, 3)C . (3, 5)D . (3, 1)
考题
下列程序对加号进行了重载,划线部分的语句是______。 include include class
下列程序对加号进行了重载,划线部分的语句是______。include<iostream.h>include<math.h>class Triangle{int x,y,z;double area;public:Triangle(int i,int j,int k){double s;x=i;y=j;z=k;s=(x+y+z)/2.0;area=sqrt(s*(s-x)*(s-y)*(s-z));}void disparea( ){cout<<"Area="<<area<<endl;}friend double operator+(Triangle tl,Triangle t2){______}};void main( ){Triangle tl(3,4,5),t2(5,12,13);double s;cout<<"tl:";t1. disparea( );cout<<"t2:";t2. disparea( );s=t1+t2:cout<<"总面积:="<<s<<endl;}
考题
有以下程序: include using namespace std; class MyClass { public: static int s; M
有以下程序:include<iostream>using namespace std;class MyClass{public:static int s;MyClass();void SetValue(int val);};int MyClass::s=0;MyClass::MyClass(){S++;}void MyClass::SetValue(int val){s=val;}int main(){MyClass my[3],*p;p=my;for(int k=0;k<3;k++){p->SetValue(k+1);p++;}cout<<MyClass::s<<end1;return 0;}运行后的输出结果是______。
考题
执行下面程序输出的是【】。 include using namespace std;template T tot
执行下面程序输出的是【 】。include <iostream>using namespace std;template <typename T>T total(T *data){Ts=0;while( *data) s+=*data++;return s;}int main(){int s[]={1,3,5,7,0,2,4,6,8};cout<<total(s);return 0;}
考题
有如下程序:includeusing namespace std;class Base{int x;public:Base(int n=0):x(n
有如下程序: #include<iostream> using namespace std; class Base{ int x; public: Base(int n=0):x(n){cout<<n;} int getX( )const{return x;} }; class Derived:public Base{ int y; public: Derived(int m,int n):y(m),Base(n){tout<<m;} Derived(int m):y(m){cout<<m;} }; int main( ){ Derived dl(3),d2(5,7); return 0; } 程序的输出结果是A.375B.357C.0375D.0357
考题
有如下程序: include using namespace std; class Part{ public:
有如下程序: #include <iostream> using namespace std; class Part{ public: Part(int x=0):val(x) { cout<<val; } ~Part() { cout<<val; } private: int val; }; class Whole { public: Whole(int x, int y, int z=0):p2(x),p1 (y),val(z) { cout<<val; } ~whole() { cout<<val; private: Part p1,p2; int val; }; int main() { Whole obj (1,2,3); return 0; }程序的输出结果是A.123321B.213312C.213D.123123
考题
有如下程序: include using namespace std; class Sample { frien
有如下程序: #include <iostream> using namespace std; class Sample { friend long fun(Sample s); public: Sample(long a) {x=a;} private: long x; }; long fun(Sample s) { if(s.x < 2) return 1; return s.x * fun(Sample(s.x-1)); } int main() { int stun = 0; for (int i=0; i<6; i++) {sum += fun(Sample(i));} cout << sum; return 0; }运行时输出的结果是A.120B.16C.154D.34
考题
阅读下面程序,写出输出结果。#includeusing namespace std ;class A{int a, b;public :A() { a = b = 0; }A( int aa, int bb){a = aa;b = bb;cout a b endl ;}};int main(){A x, y(2,3);return 0;}
考题
若有如下程序:includeusing namespaces std;int s=0;class sample{ static int n;pub
若有如下程序: #include<iostream> using namespaces std; int s=0; class sample { static int n; public: sample(int i) { n=i; } static void add() { s+=n; } ); int sample::s=0; int main() { sample a(2),b(5); sample::add(); cout<<s<<endl; return 0; } 程序运行后的输出结果是A.2B.5C.7D.3
考题
有以下程序include using 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. x;}int main(){ sample s1(20),s2(30); cout<<square(s2)<<end1; return 0;}执行结果是( )。A.20B.30C.900D.400
考题
下列程序的输出结果是【】 includeusing namespace std; template T total
下列程序的输出结果是【 】include<iOStream>using namespace std;template <typename T>T total (T*datA){T s=0;while(*datA){s+=*data++;}return s;}int main(){int x[]={2,4,6,8,0,12,14,16,18};cout<<total(x)<<end1;return 0;}
考题
有如下程序:includeusing namespace std;class Part{public:Part(int x=0):val(x){co
有如下程序: #include<iostream> using namespace std; class Part{ public: Part(int x=0):val(x){cout ~Part( ){cout<<val;} pritave: int val; }; class Whole{ public: Whole(int x,int Y,int z=0):p2(x),p1(Y),val(z){cout<<val;} ~Whole( ){cout<<val;} pritave: Part p1,p2; int val; f; int main( ){ Whole obj(1,2,3); return 0; } 程序的输出结果是A.123321B.213312C.213D.123123
考题
有如下程序:includeusing namespace std;class Part{public:Part(int x=0):val(x) {c
有如下程序: #include<iostream> using namespace std; class Part{ public: Part(int x=0):val(x) {cout<<val;} ~Part(){cout<<val;} private: int val; }; class Whole{ public: Whole(int x ,int y, int z=0):p2(x),p1(y),val(z){cout<<val;} ~Whole(){cout<<val;} private: Part p1,p2; int val; }; int main() Whole obj(1,2,3); return 0; } 程序的输出结果是( )。A.123321B.213312C.213D.123123
考题
有如下程序: include using namespace std; template T total(T * data)
有如下程序:include<iostream>using namespace std;template<typename T>T total(T * data) {T s=0;While(* data)s+ = *data + +;return s;}int main(){int x[]:{2,4,6,8, 10, 12, 14, 16, 18};cout<<total(x);
考题
下面程序的输出结果是【】。 include using namespace std; class A {int a,b; public:A
下面程序的输出结果是【 】。include <iostream>using namespace std;class A{int a, b;public:A(){a = b = 0;}A(int aa, int bb ) : a(aA) , b(bB){cout <<"a="<<a<<","<<"b="<<b<<",";}~A(){cout<<"D";};int main ( ){A x, y(2, 3);return 0;}
考题
将下面程序补充完整。 include using namespace std; class Base{ public: 【 】fun(){r
将下面程序补充完整。include <iostream>using namespace std;class Base{public:【 】 fun(){return 0;} //声明虚函数};class Derived:public Base{public:x,y;void SetVal(int a,int b){}int fun(){return x+y;}};void 【 】 SetVal(int a,int b){x=a;y=b;} //类Derived成员函数void main(){Derived d;cout<<d.fun()<<endl;}
考题
有以下程序:include using namespace std;class A{private: int x,y;public: void se
有以下程序: #include <iostream> using namespace std; class A { private: int x,y; public: void set (int i,int j) { x=i; y=j; } int get_y() { return y; } }; class box { private: int length,width; A label; public: void set(int 1,int w, int s,int p) { length=1; width=w; label.set(s,p); } int get_area() { return length*width; } }; int main() { box small; small.set(2,4,1,35); cout<<small.get_area()<<end1; return 0; } 运行后的输出结果是( )。A.8B.4C.35D.70
考题
有如下程序: include using namespace std; class Base{ int x; pu
有如下程序: #include<iostream> using namespace std; class Base{ int x; public: Base(int n=0):x(n){cout<<n;) int getX()const{return x;} }; class Derived:public Base{ int y; public: Derived(int m,int n):y(m,)Base(n){cout<<m;} Derived(int m):y(m){cout<<m;} }; int main(){ Derived d1(3),d2(5,7) return 0; }运行时的输出结果是A.375B.357C.375D.357
考题
有如下程序: include using namespace std; class Sac{ int n; public: Sac():n(4){co
有如下程序:include<iostream>using namespace std;class Sac{int n;public:Sac():n(4){cout<<n;}Sac(int k):n(k){cout<<n;}~Sac(){cont<<n+n;}};int main(){Sac s1,*s2;s2=new Sac(3);delete s2;return 0;}运行时的输出结果是______。
考题
有以下程序:include using namespace std;class sample{private: int x; static int
有以下程序:#include <iostream>using namespace std;class sample{private: int x; static int y;public: sample(int a); static void print(sample s);};sample:: sample(int a){ x=a; y+=x;}void sample:: print(sample s){ cout<<"x="<<s. x<<",y="<<y<<end1;}int sample:: y=0;int main(){ sample s1(10); sample s2(20); sample:: print(s2); return 0;}程序运行后的输出结果是( )。A.x=10,y=20B.x=20,y=30C.x=30,y=20D.x=30,y=30
考题
有以下程序include using namespace std; class sample { private: int x; public:
有以下程序 #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.x; } int main() { sample s1 (20),s2(30); cout<<square(s2)<<end1; return 0; } 执行结果是A.20B.30C.900D.400
考题
有如下程序: include using namespaee std; class A{ public: A( ){cout
有如下程序:include<iostream>using namespaee std;class A{public:A( ){cout<<"A";}~A( ){cout<<"A";}};class B{A a;public:B( ){cout<<"B";}~B( )t cout<<"B";}};int main( ){B b;return 0;}程序的输出结果是______。
考题
阅读下面程序:include template class TAdd{private:T x, y;public:TAdd(T
阅读下面程序:include <iostream.h>template <class T>class TAdd{private:T x, y;public:TAdd(T a, T b){x=a;y=b;}T add(){return x +y;}};void main( ){TAdd<int>a(5,6);TAdd<double>b(2.4,5.8);cout<<"s1 ="<<A. add()<<",";cout<<"s2="<<B, add()<<end1;}写出该程序的运行结果:【 】。
考题
下面程序的输出结果是()。includeusing namespace std;templateT max(T x,T
下面程序的输出结果是( )。 #include<iostream> using namespace std; template<class T> T max(T x,T y) { return(x>= y ? x:y);} template<class T> T max(T x,T y,T z) { T t; t=(x>=y ? x:y); return(t>=z ? t:z); } void main(){ int x = 10,y=18,maxi; float a = 1.2,b = 3.2,c = 2,max2; max1 = max(x,(int)c); max2 = max(a,b,(float)y); cout<<maxi<<endl; cout<<max2<<endl;A.18 3.2B.10 18C.10 3.2D.编译出错
考题
有如下程序:includeusing namespace std;int s=0;class sample{ static int n;public
有如下程序: #include<iostream> using namespace std; int s=0; class sample { static int n; public: sample(int i) { n=i; } static void add() { s+=n; } }; int sample::s=0; int main() { sample a(2),b(5); sample::add(); cout<<s<<endl; return 0; } 程序运行后的输出结果是A.2B.5C.7D.3
考题
下面程序输出的结果是( )。 include using namespace std; class A{
下面程序输出的结果是( )。 #include<iostream> using namespace std; class A{ int X; public: A(int x):x(++x){} ~A(){cout<<x;} }; class B:public A{ int y; public: B(int y):A(y),y(y){} ~B(){cout<<y;}; }; void main(){ B b(3); }A.34B.43C.33D.44
考题
有如下程序:include using namespace std;class shapes{protected: int x, y;public:
有如下程序: #include <iostream> using namespace std; class shapes { protected: int x, y; public: void setvalue(int d, int w=O) { x=d; y=w; } virtual void disp()=O; }; class square : public shapes { public: void disp () { cout<<x*y<<end1; } }; int main ( ) { shapes *ptr; square s1; ptr=s1; ptr->setvalue (10, 5) ;ptr->disp(); return 0; } 执行上面的程序将输出( )。A.50B.5C.10D.15
考题
下列程序段的执行结果为()。includeusing namespace std;class example{int n;public:
下列程序段的执行结果为( )。 #include<iostream> using namespace std; class example{ int n; public: example(int i){n=i;} void add(){s+=n;} static int s; void pr(){ cout<<s<<endl; } }; int example::s=0; int fuc(char *x); int main(){ example x(2),y(3),z(4); x. add(); y. add(); z.pr(); return 0; }A.2B.3C.5D.6
热门标签
最新试卷