error: type 'nested class' is not derived from type 'class'
Dec 8, 2014 at 9:34pm UTC
What does this error message mean?
C:\Users\wolf\Documents\demo_MinGW>g++ staticDestroy4.cpp
staticDestroy4.cpp:25:35: error: type 'Wrapper::Employee' is not derived from ty
pe 'Wrapper'
Manager& Employee::refManager = manager1;
^
The error comes from line 25:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34
#include <iostream>
class Wrapper
{
public :
class Manager
{
private :
int j;
public :
Manager(): j(0) { }
void print() { std::cout << " " << j++; }
};
class Employee
{
private :
static Manager& refManager;
public :
void fn() { refManager.print(); }
};
Manager manager1;
Manager& Employee::refManager = manager1;
//error: type 'Wrapper::Employee' is not derived from type 'Wrapper'
};
/* this static member initilization compiles:
Wrapper::Manager manager0;
Wrapper::Manager& Wrapper::Employee::refManager = manager0;
*/
int main()
{
}
Thank you.
Topic archived. No new replies allowed.