有如下程序:
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;
}
运行时的输出结果是______。
第1题:
第2题:
有下列程序: #include<iostream> using namespace Std; class Test { public: Test() {n+=2;} ~Test() {n-=3;} static int getNum(){return n;} private: static int n; }; int Test∷n=1; int main()
A.n=0
B.n=l
C.n=2
D.n=3
第3题:
有如下程序:#include <iostream>using namespace std;class Base{private: char c;public: Base(char n) :c(n){} ~Base() { cout<<c; } };class Derived: public Base{private: char c; public: Derived(char n):Base(n+1),c(n) {} ~Derived() { cout<<c; }};int main (){ Derived obj ('x'); return 0;}执行上面的程序净输出
A.xy
B.yx
C.x
D.y
第4题:
有如下程序: #include <iostream> using namespace std; int s=0; class sample { static int n; public: sample(int i) { n=i; } static void add() { s+=n; } };
A.2
B.5
C.7
D.3
第5题:
有如下程序: #include<iostream>#include<iosream> using namespace std; class BASE{ char c; public; BASE(char n):c(n){} virtual ~ BASE(){cout<<c;} }; class DERIVED; public BASE{ char c; public: DERIVED (char n): BASE (n+1)
A.XY
B.YX
C.X
D.Y
第6题:
有如下程序:
#include<iostream>
using namespace std;
class Pair{
int m, n;
public:
Pair(int j, int k):m(j), n(k){}
int get(){return m;}
int get()const{return m+n;)
};
int main() {
Pair a(3, 5);
const Pair b(3, 5);
cout<<a. get()<<b. get();
return 0;
}
运行时的输出结果是( )。
A) 33
B) 38
C) 83
D) 88
A.
B.
C.
D.
第7题:
有如下程序: #include<iostream.h> Using namespace std; Class Demo { public: Demo(){ cout<<“default constructor\n”;} Demo(const Demo &x){ cont<<“copy constructor\n”;} }; Demo usercode(Demob){Demo c(b);return c;} int main() {
A.1和1
B.1和2
C.2和3
D.2和4
第8题:
有如下程序: #include<iostream> using namespqce Std; class TestClass { private; Char C; public; TestClass(char n):c(n){} ~TestClass() { cout<<c; }; class TestClassl:public TestClass { private: Char C; public:
A.xy
B.yx
C.x
D.y
第9题:
有如下程序: #include<iostream> using namespace std; Class Test { public: Test() {n+=2;} ~Test() {n-=3;} static int getNum() {return n;} private: static int n; }; int Test::n=1; int main() { Test*p=new Test;
A.n=0
B.n=1
C.n=2
D.n=3