CPP-2 online test, online practice test, exam, quiz

Online Practice Test > CPP-2        (Total 24 questions)        (Time spent 0:0)

1. What is the output of the following code snippet?

class test {
public:
static int n;
test () { n++; };
~test () { n--; };
};

int test::n=0;
int main () {
test a;
test b[5];
test * c = new test;
cout << a.n << endl;
delete c;
cout << test::n << endl;
return 0;
}




   View Answer and Discussion
Advertisement