A
Alfonso Morra
I have a class that contains a nested class. The outer class is called
outer, and the nested class is called inner. When I try to compile the
following code, I get a number of errors. It is not obvious to me, where
I'm going wrong (the compiler messages do not seem to make much sense).
here is the code:
outer class declared as ff in "outer.h":
#include "inner.h"
class outer {
public:
outer() ;
~outer() ;
private:
class inner ;
inner m_inner ;
public:
void dothis(void){ m_inner.dothis() ; }
void dothat(void){ m_inner.dothat() ; }
};
inner class declared as follows in "inner.h" :
#include "outer.h"
class outer::inner {
friend class outer ;
outer::inner() ;
~outer::inner() ;
void dothis( void ) {} ;
void dothat( void ){} ;
}
Here is main() function:
#include "outer.h"
#include "inner.h"
int main(int argc, char* argv[]) {
outer y ;
y.dothis() ;
y.dothat() ;
}
I will be very grateful for advice to help me fix this as I spent a
large portion of yesterday trying to fix this by reffering to various
documentation - none of ehich actually addresses the issue of using or
delegating to a nested class as I'm trying to do above. MTIA
outer, and the nested class is called inner. When I try to compile the
following code, I get a number of errors. It is not obvious to me, where
I'm going wrong (the compiler messages do not seem to make much sense).
here is the code:
outer class declared as ff in "outer.h":
#include "inner.h"
class outer {
public:
outer() ;
~outer() ;
private:
class inner ;
inner m_inner ;
public:
void dothis(void){ m_inner.dothis() ; }
void dothat(void){ m_inner.dothat() ; }
};
inner class declared as follows in "inner.h" :
#include "outer.h"
class outer::inner {
friend class outer ;
outer::inner() ;
~outer::inner() ;
void dothis( void ) {} ;
void dothat( void ){} ;
}
Here is main() function:
#include "outer.h"
#include "inner.h"
int main(int argc, char* argv[]) {
outer y ;
y.dothis() ;
y.dothat() ;
}
I will be very grateful for advice to help me fix this as I spent a
large portion of yesterday trying to fix this by reffering to various
documentation - none of ehich actually addresses the issue of using or
delegating to a nested class as I'm trying to do above. MTIA