This compiler does not want to compile:
class MainClass { public: ... private: class NestedClass {
The compiler says:
error: 'class MainClass :: NestedClass' is private
However, if I made NestedClass public , it will work.
Why is this not working? Is it not as if I were exporting a nested class through a public method? This is just a private method that returns a pointer to a private class. Any ideas?
Thanks!
Update
Fixed half columns. They are not a problem. Do not write class before NestedClass.
This is where the error message appears:
MainClass.h: In the function 'MainClass :: NestedClass * getNestedClassFor (int i)':
MainClass.h: 39: error: 'class MainClass :: NestedClass' is private
MainClass.cpp: 49: error: in this context
Here is the part of the .cpp file that also complains:
class MainClass::NestedClass * getNestedClassFor(int i)
source share