I started studying classes and now I faced a problem. I’m trying to put all my variables into a class, but I get errors:
main.cpp|6|error: expected identifier before string constant|
main.cpp|6|error: expected ',' or '...' before string constant|
main.cpp|7|error: expected identifier before string constant|
main.cpp|7|error: expected ',' or '...' before string constant|
Although when I make them global everything works fine
class Kauliukas{
ifstream inFile("inFile.in");
ofstream outFile("outFile.out");
int n, akutes[100],k=0;
void ivedimas();
void skaiciavimas();
void isvedimas();
};
What’s the problem?
Initialization goes in the constructor. That’s different than, for instance, C#.
You must define a constructor like