samedi 1 novembre 2014

Strange issue with static const member variable changing value


Vote count:

0




Suppose I have a class with a static const member variable,



class foo {
public:
foo(){}
bool foo(int someNum){return num > someNum}
private:
static const int num;
};

const int foo::num = 321;


If I decide to debug this in Visual Studio 2013 something odd is happening for me; foo(2) will return false when 321 > 2 is obviously true. When I debug this, the debugger tells be that the value of num is actually 1 instead of 321. Anyone have any ideas of what can be causing this?



asked 31 secs ago







Strange issue with static const member variable changing value

Aucun commentaire:

Enregistrer un commentaire