#include<iostream>
using namespace std;
class Myclass {
public:
static int i;
Myclass()
{
i=3;
Fun();
}
void Fun()
{
i--;
if(i>0)
Fun();
cout<<i;
i++;
}
};
int main()
{
Myclass *p = new Myclass();
return 0;
}
What's wrong with this?
undefined reference to Myclass::i' errors occur.
But If I remove Myclass *p = new Myclass();
, then the program executes. What should be the output of this? As there is a line as static int i;
I suggest the output 000
Would anybody please explain?
Thanks in advance