For some reason this code doesn't work
class Media
{
private:
static int number;
public:
void addMediaType();
};
void Media :: addMediaType()
{
number=1;
}
How can I refer to my static number from my public method ?
For some reason this code doesn't work
class Media
{
private:
static int number;
public:
void addMediaType();
};
void Media :: addMediaType()
{
number=1;
}
How can I refer to my static number from my public method ?
Media::number = 1;Originally Posted by probine
But you have to initialise it somewhere first. The initialisation should take place outside of any class member and should be done only once, something like that:
Qt Code:
//header class X{ static int var; }; //implementation int X::var = 1;To copy to clipboard, switch view to plain text mode
Bookmarks