Questions of copy constructor

From: away (Gusalpine_at_spambs.com)
Date: 09/14/04


Date: Tue, 14 Sep 2004 14:16:01 GMT

1. When a class defined with a member of pointer type, it's necessary to
have a copy constructor and assignment operator.

If don't pass objects of such class as value in a function and don't do
assignment, should copy constructor and assignment operator be unnecessary?

2. If a base class have a pointer member, should its derived classes also
need copy constructor and assignment operator, no matter if a derived class
itself has a pointer member or not?

3. If such a pointer member of pointer type of "void", such void type can be
casted to any other type at runtime, how to code a copy constructor for such
a member?

Thanks for help!



Relevant Pages

  • Re: Questions of copy constructor
    ... > have a copy constructor and assignment operator. ... Depends if this pointer is an owning pointer or not. ... should copy constructor and assignment operator be unnecessary? ... If a base class have a pointer member, ...
    (comp.lang.cpp)
  • Re: C++ 101 dumb question
    ... Its action is to copy the data members of the class, ... If one of those members is a pointer, ... have it's own copy constructor would the default copy constructor call ... as a copy of the class being returned is placed on the stack for the ...
    (microsoft.public.vc.language)
  • Re: C++ 101 dumb question
    ... Yep I do comprehend the difference between a pointer and the data it ... If you have a CMyClass a; ... What does the signature of a copy constructor look like? ... Its action is to copy the data members of the class, ...
    (microsoft.public.vc.language)
  • Re: Questions of copy constructor
    ... >> have a copy constructor and assignment operator. ... assignment operator is that a class manages or "owns" some resource. ... Such classes often contain pointers, but the presence of a pointer ... >> itself has a pointer member or not? ...
    (comp.lang.cpp)
  • Re: Question about arrays in objects
    ... >>I want to create a 2d array as an object member. ... > handled in the constructor, you just can't use a plain old array. ... > that is where using a pointer would come in. ...
    (alt.comp.lang.learn.c-cpp)