有如下程序: #includeiostream usingnamespacestd; classMyClass{ public: MyClass(intx):val(x){} voidPrint()const{cout"const:val="val\t;} voidPrint(){cout"val="valt;} private: intval; }; intmain(){ constMyClassobj1(10); MyClassobj2(20);obj1.Print(); obj2.Print(); return0; } 程序的输出结果是( )。A.va1=10const:va1=20B.const:va1=10const:va1=20C.const:va1=10val=20D.val=10va1=20
有如下程序: #include<iostream> usingnamespacestd; classMyClass{ public: MyClass(intx):val(x){} voidPrint()const{cout<<"const:val="<<<val<<\t;} voidPrint(){cout<<"val="<<val<<t;} private: intval; }; intmain(){ constMyClassobj1(10); MyClassobj2(20);
obj1.Print(); obj2.Print(); return0; } 程序的输出结果是( )。
A.va1=10const:va1=20
B.const:va1=10const:va1=20
C.const:va1=10val=20
D.val=10va1=20
相关考题:
有以下程序: 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 include using namespace std; cla 有如下程序 #include <iostream> #include <iomanip> using namespace std; class MyClass { public: MyClass() { cout<<'A'; } MyClass(char c){ cout<<c; } ~MyClass(){ cout<<'B'; } }; int main( ) { MyClass p1,*p2; p2=new MyClass('X'); delete p2; return 0; } 执行这个程序屏幕上将显示输出A.ABXB.ABXBC.AXBD.AXBB
有如下程序: nclude using namespace Std; Class MyClass{ public: 有如下程序: #nclude<iostream> using namespace Std; Class MyClass{ public: MyClass(int i=0){cout<<1;} MyClass(constMyClassx){cout<<2;} MyClass perator=(const MyClassx){cout<<3;return*this;} ~MyClass(){cout<<4;} }; int main(){ MyClass obj1(1),obj2(2),obj3(obj1); return 0: } 运行时的输出结果是( )。A.112444B.11114444C.121444D.11314444
有如下程序: include using namespace std; class MyClass { public: 有如下程序: #include <iostream> using namespace std; class MyClass { public: MyClass() { ++count; } ~MyClass() { --count; } static int getCount() { return count; } private: static int count; }; int MyClass::count=0; int main() { MyClass obj; cout<<obj.getCount(); MyClass *ptr=new MyClass; cout<<MyClass::getCount(); delete ptr; cout<<MyClass::getCount(); return 0; }程序的输出结果是A.121B.232C.221D.122
有如下程序:includeusing namespace std;class MyClass{public:MyClass(int x):val(x 有如下程序: #include<iostream> using namespace std; class MyClass{ public: MyClass(int x):val(x){} void Print()const{cout<<“const:val=”<<<val<<‘\’;} void Print(){cout<<“val=”<<val<<‘t’;} private: int va1; }; int main(){ consA.val=10 const:val=20B.const:val=10 const:val=20C.const:val=10 val=20D.val=10 val=20
有以下程序:includeusing namespace std;class MyClass{public: MyClass(); ~MyClass 有以下程序: #include<iostream> using namespace std; class MyClass { public: MyClass(); ~MyClass(); void SetValue(int val); private: static int i; }; int MyClass::i=0; MyClass::MyClass() { i++; cout<<i; } MyClass::~MyClass() { i--; cout<<i; } void MyClass::SetValue(int val) { i=val; } int main() { MyClass*my[2]; int k; for(k=0;k<2;k++) my[k]=new MyClass; for(k=0;k<2;k++) delete my[k]; return 0; } 运行后的输出结果是( )。A.1210B.1100C.1234D.输出结果不确定
有以下程序:includeusing namespace std;class MyClass{public:MyClass(int n){numbe 有以下程序: #include<iostream> using namespace std; class MyClass { public: MyClass(int n){number=n;} //拷贝构造函数 MyClass(MyClassother) {number=other.number;} ~MyClass() {} private: int number; }; MyClass fun(MyClass p)A.5B.4C.3D.2
有如下程序include include using namespace std;class MyClass {public:M 有如下程序#include <iostream>#include <iomanip>using namespace std; class MyClass {public:MyClass(){ cout<<'A'; }MyClass(char c){ cout<<c; }~MyClass(){ cout<<'B'; }};int main() {MyClass p1,*p2;p2=new MyClass('X');delete p2;return 0;}执行这个程序屏幕上将显示输出( )。A.ABXB.ABXBC.AXBD.AXBB
有如下程序:includeusing namespace std;class MyClass{public:MyClass(){++count;}~ 有如下程序: #include<iostream> using namespace std; class MyClass{ public: MyClass(){++count;} ~MyClass(){--count;} static int getCount(){return count;} private: static int count; }; int MyClass::count=0; int main(){ MyClA.121B.232C.221D.122
如下程序的输出结果是includeusing namespace std;class MyClass{public:MyClass(int 如下程序的输出结果是 #include<iostream> using namespace std; class MyClass{ public: MyClass(int i=0){cout<<1;} MyClass(const MyClass&x)}cout<<2;} }; int main( ){ MyClass objl(1),obj2(2),ohj3(objl); return 0; }A.112B.111C.121D.113