J
Johs
I have this in a file called bas.h:
#ifndef BAS_H_
#define BAS_H_
class GeoObj {
public:
void draw() const;
int getNum();
private:
int num = 10;
};
#endif /*BAS_H_*/
But I get the error:
bas.h:10: error: ISO C++ forbids initialization of member ‘num’
I have also tried to change "int num = 10;" to "static int num = 10";
but it still gives an error. Why does it give an error to initialize a
private field?
#ifndef BAS_H_
#define BAS_H_
class GeoObj {
public:
void draw() const;
int getNum();
private:
int num = 10;
};
#endif /*BAS_H_*/
But I get the error:
bas.h:10: error: ISO C++ forbids initialization of member ‘num’
I have also tried to change "int num = 10;" to "static int num = 10";
but it still gives an error. Why does it give an error to initialize a
private field?