#include <iostream>
#include "ClassStudent.h"
using namespace std;
/* run this program using the console pauser or add your own getch, system("pause") or input loop */
int main(int argc, char** argv) {
Student a(1,'m','m');
Student::showCount();
return 0;
}
ClassStudent.cpp
#include "ClassStudent.h"
using namespace std;
int Student::count=0;
void Student::showCount()
{
cout<<count<<endl;
}
ClassStudent.h
class Student{
public:
Student(int num=0,char name='a',char sex='f'):num(num),name(name),sex(sex){
count++;
}
void showCount();
private:
int num;
char name;
char sex;
static int count;
};