Thread: copy constructor

  1. #1
    Registered User
    Join Date
    Aug 2001
    Posts
    411

    copy constructor

    can someone show me a simply class that uses a copy constructor, I cant find any examples in msdn.

  2. #2
    Just because ygfperson's Avatar
    Join Date
    Jan 2002
    Posts
    2,490
    a copy constructor simply makes a copy of another object

    Code:
    //i could be wrong... it's been a long time
    class Goldfish {
    public:
      Goldfish ();
      int trait1;
      char trait2;
      Goldfish (Goldfish& temp) {
        trait1 = temp.trait1;
        trait2 = temp.trait2;
    
    
      }
    
    
    
    };
    it's a very simple example, but it should work.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Copy constructor
    By dude543 in forum C++ Programming
    Replies: 26
    Last Post: 01-26-2006, 05:35 PM
  2. illegal copy constructor required?
    By ichijoji in forum C++ Programming
    Replies: 1
    Last Post: 03-08-2005, 06:27 PM
  3. Linked list copy constructor issue
    By Craptastic! in forum C++ Programming
    Replies: 1
    Last Post: 08-03-2003, 08:30 PM
  4. Quick ? on copy constructor
    By Traveller in forum C++ Programming
    Replies: 3
    Last Post: 05-03-2002, 10:31 AM
  5. Using strings with the copy constructor
    By Unregistered in forum C++ Programming
    Replies: 3
    Last Post: 08-29-2001, 03:04 PM