Hi all,
what do you think of the following?
Example 1 compiles:
Example 2 does not compile:
As far as I understand C++, the compiler must complain "error C2597: illegal reference to data member 'MyClass::itsFlag' in a static member function" for both examples, not only for the second, because itsFlag is a non-static variable used in a static function!
I am *slightly* confused.
P.S. Using MSVC++ 6.0 Enterprise + Service Pack 5
what do you think of the following?
Example 1 compiles:
Code:
class MyClass
{
public:
static void func();
private:
bool itsFlag;
};
void MyClass::func()
{
int i = itsFlag ? 0 : 1;
}
Example 2 does not compile:
Code:
class MyClass
{
public:
static void func();
private:
bool itsFlag;
};
void MyClass::func()
{
bool b = itsFlag;
}
As far as I understand C++, the compiler must complain "error C2597: illegal reference to data member 'MyClass::itsFlag' in a static member function" for both examples, not only for the second, because itsFlag is a non-static variable used in a static function!
I am *slightly* confused.
P.S. Using MSVC++ 6.0 Enterprise + Service Pack 5