I am currently having a problem with templates. I have this public class that implements the template method:
namespace Private { class InternalClass; } namespace Public { class PublicClass { public: PublicClass(); virtual ~PublicClass(); template<class T> bool Add(bool primary); private: Private::InternalClass* _pInternal; }; template<class T> bool PublicClass::Add(bool primary) { return _pInternal->Add<T>(primary); } }
The inner class is implemented as follows:
namespace Private { class InternalClass { public: InternalClass(); virtual ~InternalClass(); template <class T> bool Add(bool primary); }; template<class T> bool InternalClass::Add(bool primary) { return false; } }
Since this inner class header will not be available with the provided sources, I have to forward it to the PublicClass header, and I will add the include in PrivateClass.h to the PublicClass.cpp file.
1) Any idea why I am getting the following error:
error: member access to partial type 'Private :: InternalClass' / note: forward> declaration 'Private :: InternalClass'
2) What would be the best way to hide the implementation of PublicClass :: Add ()?
UPDATED
The cause of the error is 1) because of this , as pointed out by Cornstalks.
For 2), how can I hide my implementation without including PrivateClass.h in the PublicClass header file?
source share