Is the nested class (Y) derived from interface too? Is it declared in the global scope of the class containing it (X)? What compilation errors do you get exactly?
namespace N
{
class interface
{public:
pure virtual functions
};
class X: public interface
{
public:
class Y
{
stuff related to Y
};
another nested class
{
};
};
class derived_class:public shape
{
};
};
The error i get is;
error C2664: 'std::vector<_Ty>::push_back' : cannot convert parameter 1 from 'N::X::Y *' to 'N::X *const &'
with
[
_Ty= N :: interface*
]
Reason: cannot convert from 'N::X::Y *' to 'N::interface *const '
Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
As you can see, class Y isn't derived from interface. I think this is the cause of the problem. Try defining class Y like this:
1 2 3 4 5 6 7 8 9 10
class X: public interface
{
public:
class Y: public interface //<-add this here!
{
//stuff related to Y
};
//...
};
But if it doesn't make sense that Y should be derived from interface then don't do it... Find another way to solve it, redesigning your inter-class relationships. Why do you need the nested classes anyway? What are you trying to do?
Hi, Sorry for late reply, have been without internet for a few days but didn't want to appear rude. I changed the structure of my code so everthing works as intended now.