I have a very large object and to keep the interface as small as possible I would like to put the declaration of some classes that only have a meaning inside of the large object in the private section.
So I suppose to make the object better usable.
The project the object is to put in is a big one too and so I dont want to make it needlessly complicated (name conflicts, large interface...)
the above code should work.
the mistake was a muddle between 2 functions.
I put the code I wanted to stick into a function into another one, and the compiler told me: I dont know this class...
Since the private class is actually an internal thingie you could also consider declaring it in the implementation (.cpp).
In the interface class it is referred to by pointer. Then the only implact on the interface would be a forward declaration.
Sample:
---- .h ----
// Forvard decl.
class MyInternal;
class MyInterface
{
public:
MyInterface();
~MyInterface();
// Some stuff
private:
MyInternal* mInternal;
};
thx, good idea, cause I get a problem with too long names when I use std::list
(std::list <MyClass::MyInternalClass,...)
Think it will shift this problem to later times
to bee continued ...
can you answer the following question:
I need this MyInternalClass only inside the private functions
If I forward "class MyInternalClass;" outside MyClass everyone knows that I use this
If I forward it inside of MyClass the names are too long...
What can I do not to show the internal class and not to get this compiler warning about too long names (without disable warning and without showing the internal class), is there a way (maybe I can change compiler setup to use longer names...)
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.