Re: Static data of a class
static variables must be defines as well as declared:
Code:
class REC
{
private:
static int n; //Dado que será único na classe e alterado por todos os objetos
public:
REC() {n++;} // Construtor
int getrec() const {return n;}
};
int REC::n; // define
Also, it should be int main, not void main.
Re: Static data of a class
Excuse my ignorance, but I could not understand his explanation. You can fix mei code so I can see what is wrong? I will be very grateful.
Re: Static data of a class
1) I did fix your code ... see the line that I added in my first post:
Code:
int REC::n; // define
2) google: defining static member variables c++