0

I am looking for a solution to the following problem: There are some subclasses inside one class, I want to put them into another header or cpp file.

Example in main.h:

class main
{
public:
    class sub
    {
        int value;
        sub()
            {value=1;}

    };

    main(void);
    ~main(void);
};

So far, it's fine. But i want to put main and sub in seperate header files.

like in newmain.h:

#include newsub.h
class newmain
    {
    public:
        class newsub;

    int count;
    newsub thissub;
    int count;
    newmain(void)
        {count=1;}

    ~newmain(void);
};

as well as in newsub.h:

#include"newmain.h"
class newmain::newsub
{
    public:
        int value;
        newsub()
            {value=1;}
}

I tired to declare newsub as virtual, but in this case the compiler tells me, it won't declare anything...?

Farhad
  • 4,119
  • 8
  • 43
  • 66

0 Answers0