top button
Flag Notify
    Connect to us
      Site Registration

Site Registration

Why reference of an object is needed in defining copy constructor?

0 votes
483 views

We define copy constructor using
A(const A & obj)

Why reference (&) is needed?
Why we are not allowed to use.

A(const A obj)
posted Jun 7, 2016 by anonymous

Share this question
Facebook Share Button Twitter Share Button LinkedIn Share Button

1 Answer

+1 vote

Reference is needed so that we need to access the same instance which the reference is pointing to, otherwise it will create another instance and first of all we need to have const & in the constructor

answer Jun 8, 2016 by Rajendra Stalekar
...