Find the error..

The definition of the class AA got some error. Can anyone let me know whats the error in Class AA? The output should be same as in comments below..


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
  
class AA {
 int x;
public :
int getX() {
 return x;
}
};

int main () {
 cout << AA :: getX() << endl; // 0
AA* a = new AA[100];
cout << AA :: getX() << endl; //100
delete [] a;
cout << AA:: getX() << endl; // 0
closed account (48T7M4Gy)
try '#include <iostream>', then maybe 'std' etc
Error 1: To call function as AA::getX(), it should be static.

Error 2: There is no code which would calculate amount of created objects
Topic archived. No new replies allowed.