题目内容

#include using namespace std;class Test{public:static int i;static int get();Test() { i++; }};int Test::i = 0;int Test::get(){return i;}Test t;int main(){Test t;cout<

查看答案
更多问题

#include using namespace std;class Test {static int x;public:Test() { x++; }static int getX() { return x; }~Test() {cout << x << " destroying an object\n";x--;}};int Test::x = 0;int main(){cout << Test::getX() << " ";cout << sizeof(Test) << endl;return 0;}what is the output?

#include using namespace std;class Test {int x = 0;public:Test() { x++; }int getX() const{ return x; }};int main(){Test t0;cout << sizeof(t0) << endl;cout << t0.getX() << endl;const Test t1;cout << t1.getX() << endl;return 0;}what is the output?

#include#includeusing namespace std;class String {char* str;public:String(const char* s);void set(int index, char c) { str[index] = c; }char* get() { return str; }~String() { delete str; }};String::String(const char* s){int l = strlen(s);str = new char[l + 1];strcpy(str, s);}int main(){String s1("Quiz");s1.set(0, 'q');cout << s1.get() <

#include#includeusing namespace std;class String {char* str;public:String(const char* s);void set(int index, char c) { str[index] = c; }char* get() { return str; }~String() { cout << str <<" object is deleted \n"; delete str; }};String::String(const char* s){int l = strlen(s);str = new char[l + 1];strcpy(str, s);}int main(){String s1("Quiz");s1.set(0, 'q');cout << s1.get() <

答案查题题库