Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > C++ Moderated > cl***** with po...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 1 of 13 Topic 9373 of 10094
Post > Topic >>

cl***** with pointer data members.

by mpho <tjabane@[EMAIL PROTECTED] > Mar 13, 2008 at 12:31 PM

Whenever a class has a pointer data member, e.g.
class T {
     .....
     type *pointer;

     .....
};

it will have a copy constructor, the operator=, and a destructor. The
operator= will normally be defined, for instance, as
T& T::operator=(const T& other){

    if (this == &other){
       return *this;
    }
    else {
      delete pointer;
      pointer = new type;
      pointer = other.pointer;
    }
  return *this;
}

Can anybody tell me, when a class has multiple pointers (of the same
and/or different types) how is operator= defined? Thank you.

-- 
      [ See http://www.gotw.ca/resources/clcm.htm
for info about ]
      [ comp.lang.c++.moderated.    First time posters: Do this! ]
 




 13 Posts in Topic:
classes with pointer data members.
mpho <tjabane@[EMAIL P  2008-03-13 12:31:16 
Re: classes with pointer data members.
mos <moswald@[EMAIL PR  2008-03-13 16:26:25 
Re: classes with pointer data members.
Mateusz Adamczyk <mate  2008-03-13 16:31:29 
Re: classes with pointer data members.
Lance Diduck <lancedid  2008-03-13 16:33:12 
Re: classes with pointer data members.
Carl Barron <cbarron41  2008-03-13 16:42:26 
Re: classes with pointer data members.
"Thomas J. Gritzan&q  2008-03-13 23:59:24 
Re: classes with pointer data members.
Triple-DES <DenPlettfr  2008-03-15 11:43:01 
Re: classes with pointer data members.
Ulrich Eckhardt <dooms  2008-03-16 15:42:04 
Re: classes with pointer data members.
Seungbeom Kim <musiphi  2008-03-17 01:49:40 
Re: classes with pointer data members.
mpho <tjabane@[EMAIL P  2008-03-28 11:13:01 
Re: classes with pointer data members.
Mathias Gaunard <loufo  2008-03-29 05:14:56 
Re: classes with pointer data members.
=?ISO-8859-1?Q?Daniel_Kr=  2008-03-30 10:18:07 
Re: classes with pointer data members.
Ulrich Eckhardt <dooms  2008-04-09 17:56:49 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Sat Oct 11 15:06:16 CDT 2008.