Tony Johansson wrote:
Hello!!
Is it correct to say that THE ONLY TIME it's absolute necessary to define a
copy constructor and a destructor when implementing a class is when
allocating dynamic memory
//Tony
Not sure why a mention of 'copy constructor', it should have been
'constructor' only. You need a constructor and/or a destructor when you
want to do something more than what the system provides you with. For
example, open a file, etc.
You need a copy constructor when you have to create a copy of an
existing object. There is one provided by the system but you would need
your implementaion of the copy constructor if you have a pointer or an
array as your data member of the class.