You are not logged in.

#1 2015-05-26 05:52:25

hasnain
Administrator
From: Chichawatni
Registered: 2014-10-13
Posts: 8,355
Website

Snippet Code:

Question:
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;
}

Option A):
7 6
Option B):
5 6
Option C):
6 5
Option D):
6 7

Correct Answer is Option A):
7 6


Failure is the first step towards seccess.

2015-05-26 05:52:25

Advertisement
Ads By Google

Re: Snippet Code:



Board footer