Templates Need Explicit Copy Constructor?

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Referring to Managed: why do templates require an explicit copy constructor
to be defined in order to use gcnew whereas simply declaring an object as a
local (still uses managed heap of course) does not require the template to
have a default constructor defined?
 
The point I'm making is that the VC++ 2005 documentation states that a
default constructor and a default copy constructor are automatically provided
if not defined in the class. It does not explicitly discuss how this is
handled for templates but since a default constructor is automatically
defined for a template, I expected that a default copy constructor would also
be automatically defined for a template. Yet, I have found that I had to
explicitly implement a copy constructor for a template otherwise the compiler
generates an error that there is no copy constructor.

Is there an explanation for this? Can anyone elaborate?
 
Back
Top