Why this code is giving me an error that undefined reference to student::count. I am using static count and I know that static members are by default is 0 but dont know why giving me an error. Please explain me.
#include <iostream>
using namespace std;
class Student{
static int count;
string name;
public:
Student(){
count++;
cout<<"I am student"<<count<<endl;
}
int getCount() const
{
return count;
}
void setCount(int x){
count=x;
}
};
int main(){
Student stud[20];
return 0;
}
int Student::count;