can anyone please tell me the mistake in the below program.
#include <iostream>
using namespace std;
class A
{
public:
typedef int count;
static count cnt ;
};
count A::cnt = 0;
int main()
{
return 0;
}
count does not name a type
You would have to use A::count A::cnt = 0;
as your typedef is defined within the scope of class A.
i.e. either move the typedef outside the class or use scope resolution as above.
Your typedef
is inside your class and as such not globally available.
You would need to
#include <iostream>
using namespace std;
typedef int count;
class A
{
public:
static count cnt ;
};
count A::cnt = 0;
int main()
{
return 0;
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With