Anonymous wrote:
> [..]
> class C
> {
> public:
> friend class A;
> ~C(){};
>
> private:
> B(A*& parent):m_parent(parent){}
I am sure you meant
C(A* const& parent) : m_parent(parent) {}
>
> A* m_parent ;
> };
>
>
> int main( int argc, char* argv[])
> {
> A<B> ab ; // Ok
> A<C> ac ; // Croaks here ...
> };
>
>
> Class A instanstiated with B compiles ok, but when instantiated with
> class C (that accepts a *&), I get the error message - cannot convert
> parameter 1 from A const* to A* - why is that ?
>
> Why is a reference to a ptr being passed as a const ptr ?
>
> If 'this' is a const ptr during construction (I doubt this assertion
> very much), then why is it ok to use as a non-const pointer in class
> B?
'this' cannot be changed _itself_, that's why you need to put 'const'
right before the '&' in the declaration of the argument.
V
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask
|