I want to increment a global variable inside a c++ class but can not configure out how to do so
int line = 0;
int ivar = 0;
int cvar = 0;
int svar = 0;
class file {
protected:
char name[50];
string read;
string write;
ifstream readfile;
ofstream writefile;
int i;
int j;
};
I want to increment the cvar variable inside the class file. Something like
class file {
protected:
char name[50]; cvar++;
string read;
string write;
ifstream readfile;
ofstream writefile;
int i;
int j;
};
But the compiler gives error if done this way. Can someone devise an alternative method to do so?