Thread: Copy constructors........

  1. #1
    left crog... back when? incognito's Avatar
    Join Date
    Oct 2001
    Posts
    1,427

    Copy constructors........

    So I know the basics of copy constructors, I mean I know when they are called and whatnot, but could you show me an example of how you could take advantage of this and use the copy constructor for something? If I read this, I probably forgot and couldnt' find anythingn about it on my book, book is pretty huge and you're bound to forget some of these things, until you practice then a lot, or I am just plain dumb, either one.
    There are some real morons in this world please do not become one of them, do not become a victim of moronitis. PROGRAMMING IS THE FUTURE...THE FUTURE IS NOW!!!!!!!!!

    "...The only real game I thank in the world is baseball..." --Babe Ruth

    "Life is beautiful"-Don Corleone right before he died.

    "The expert on anything was once a beginner" -Baseball poster I own.


    Left cprog on 1-3-2005. Don't know when I am coming back. Thanks to those who helped me over the years.

  2. #2
    Registered User matheo917's Avatar
    Join Date
    Sep 2001
    Posts
    279
    HINT: copy constructor is called every time you "pass" something to a function, no matter if it is "by value" or "by reference" ...

    Actually what really happens is: whatever parameters you include in a call to a function they are copied onto a system stack... if you include a pointer "pass it" the copy constructor copies a pointer onto the stack and in case there's any "dynamic allocation" involved (declaration on the free store) you would have to overload the copy constructor to be able to copy all the "dynamically allocated" members one-by-one, instead of just the pointer and loosing all the remaining data........


    this was just a reference with a different look at the copy constructor.......

    ..........

    hope this helps a bit......

    Regards,
    matheo917

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Help with copy constructors
    By arya6000 in forum C++ Programming
    Replies: 2
    Last Post: 11-19-2008, 01:34 AM
  2. Copy constructors; Best practices (and private)
    By Mario F. in forum C++ Programming
    Replies: 15
    Last Post: 06-23-2006, 04:42 PM
  3. 'Passing by Refrence for Efficiency', Copy Constructors?
    By Zeusbwr in forum C++ Programming
    Replies: 4
    Last Post: 10-23-2004, 07:11 AM
  4. Copy constructors and operator=()
    By filler_bunny in forum C++ Programming
    Replies: 13
    Last Post: 08-25-2003, 07:43 AM
  5. Copy constructors and private constructors
    By Eibro in forum C++ Programming
    Replies: 5
    Last Post: 11-24-2002, 10:16 AM