I’m trying to make a class that has a simple integer with in it. Of course, it uses header files and whatnot.
Here’s the code:
class.h
class consolBuf
{
private:
int buffersize1 = 10; //Data member initializer is not allowed
int buffersize2 = 10;
static char screenBuffer[10][10]; //screenBuffer
public:
consolBuf(void);
~consolBuf(void);
void draw();
void write(int x, int y);
char get(int x, int y);
};
For some reason some reson Visual Studio keeps complaining that I can’t declare a integer in the class.h. I’ve searched everywhere and I can’t find an answer. Is there something I’m missing?
Indeed you can’t initialize members like that. If you wanted to initialize those as default values for each instance, you would do that in the constructor: