From: dududuil on
I have a compilation error I don't understand:
My code is something like this:

class A {
template <class T> class B;
....
template <class T> class B {
B();
};
};

In class A, I HAVE to have a forward declaration of class B, BEFORE the
actual declaration of B.

This code is OK - compilation passes.
BUT, if I add a destructor to B:

class A {
template <class T> class B;
....
template <class T> class B {
B();
~B();
};
};

VS6 compiler gives me the following error:
C2523: 'A::B<T>::~A' : destructor tag mismatch ???

Please help me understand this error, and maybe to find a work around

THANKS!!!
From: Ulrich Eckhardt on
dududuil wrote:
> class A {
> template <class T> class B;
> ....
> template <class T> class B {
> B();
> ~B();
> };
> };
>
> VS6 compiler gives me the following error:
> C2523: 'A::B<T>::~A' : destructor tag mismatch ???
>
> Please help me understand this error, and maybe to find a work around

Upgrade your compiler. Further, it would be helpful for further discussion
if you actually provided a piece of code that can be compiled, i.e.
no "...." in it.

Uli

--
C++ FAQ: http://parashift.com/c++-faq-lite

Sator Laser GmbH
Geschäftsführer: Thorsten Föcking, Amtsgericht Hamburg HR B62 932
From: Victor Bazarov on
Ulrich Eckhardt wrote:
> dududuil wrote:
>> class A {
>> template <class T> class B;
>> ....
>> template <class T> class B {
>> B();
>> ~B();
>> };
>> };
>>
>> VS6 compiler gives me the following error:
>> C2523: 'A::B<T>::~A' : destructor tag mismatch ???
>>
>> Please help me understand this error, and maybe to find a work around
>
> Upgrade your compiler. Further, it would be helpful for further discussion
> if you actually provided a piece of code that can be compiled, i.e.
> no "...." in it.

Actually, VC6 is *so bad* with member templates that "..." is no issue
here. There is no work-around except to pull 'B' out of 'A' or to
change the compiler as you've suggested.

V
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask