+ Reply to Thread
Results 1 to 2 of 2

Thread: In C++, why copy constructor accepts a object by reference not by value?

  1. #1
    Junior Member
    Join Date
    Feb 2012
    Posts
    29

    In C++, why copy constructor accepts a object by reference not by value?

    In C++, why copy constructor accepts a object by reference not by value?

    Is there any reason behind this principle?

    Thanks.

  2. #2
    Passing object by value requires to make a call to copy constructor.

    And you are already making a call to copy constructor it means that you are making an infinite loop of copy constructor!

    This is the reason that object should be pass by reference to copy constructor.

    Hope this helps.

+ Reply to Thread

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts