// JP opened flex table

Click to See Complete Forum and Search --> : Cannot access protected member of nested class


Jon Funk
October 25th, 2000, 06:38 PM
I'm experiencing the following error. Can anyone help?

--------------------Configuration: test - Win32 Release--------------------
Compiling...
test.cpp
D:\crud\test.cpp(17) : error C2248: 'Method' : cannot access protected member declared in class 'Outer::Inner'
D:\crud\test.cpp(5) : see declaration of 'Method'
D:\crud\test.cpp(17) : error C2352: 'Outer::Inner::Method' : illegal call of non-static member function
D:\crud\test.cpp(5) : see declaration of 'Method'
Error executing cl.exe.

test.exe - 2 error(s), 0 warning(s)



class Outer {
public:
class Inner {
protected:
void Method() { /* Do nothing */ };
};
};

class Derived : public Outer::Inner {
public:
void Function();
};

void
Derived::Function()
{
Outer::Inner::Method();
}

int main(int, char **)
{
Derived instance;
instance.Function();
return (0);
}

NMTop40
October 26th, 2000, 09:54 AM
why are you calling

Outer::Inner::Method()

why not just

Method()

As an alternative, do something like the following:

typedef Outer::Inner OutIn;



Then
class Derived : public OutIn
{
public:
void Function();
};

void Derived::Function()
{
OutIn::Method();
}




Compiles now.

Jon Funk
October 26th, 2000, 01:59 PM
Yup, just found that exact workaround on Microsoft's website. It appears to be a known bug. I really don't like this workaround but there appears to be no other choice. *sigh* Thanks for your help!

Anthony Anisimov
January 22nd, 2002, 09:31 AM
Somebody already fixed it?

WBR Saddam
mailto:saddam@hotmail.ru

//JP added flex table