T
Tom Plunket
I'm having some scoping issues, relating to the fact that
different compilers do different things. Who's doing the right
thing here?
class MyClass
{
public:
void Method();
private:
enum MyEnum
{
e0, e1, e2
};
};
void MyClass::Method()
{
struct MyStruct
{
MyEnum e; // compilation error here.
};
MyStruct ms;
ms.e = e0;
}
int main()
{
MyClass mc;
mc.Method();
}
Metrowerks Codewarrior tells me that MyStruct doesn't have access
to MyEnum due to the fact that MyEnum is a private member of
MyClass. I would (ignorantly, perhaps) assume that since
MyStruct is declared in MyClass's scope that it would have access
to MyClass private data, but... That's why I'm asking here.
MSVC.NET allows this code.
If Codewarrior is correct, is there any way to specify friendship
of MyStruct? What is the proper way to specify MyStruct's scope?
Finally, which compiler is right, and why?
thanks,
-tom!
different compilers do different things. Who's doing the right
thing here?
class MyClass
{
public:
void Method();
private:
enum MyEnum
{
e0, e1, e2
};
};
void MyClass::Method()
{
struct MyStruct
{
MyEnum e; // compilation error here.
};
MyStruct ms;
ms.e = e0;
}
int main()
{
MyClass mc;
mc.Method();
}
Metrowerks Codewarrior tells me that MyStruct doesn't have access
to MyEnum due to the fact that MyEnum is a private member of
MyClass. I would (ignorantly, perhaps) assume that since
MyStruct is declared in MyClass's scope that it would have access
to MyClass private data, but... That's why I'm asking here.
MSVC.NET allows this code.
If Codewarrior is correct, is there any way to specify friendship
of MyStruct? What is the proper way to specify MyStruct's scope?
Finally, which compiler is right, and why?
thanks,
-tom!