what is the difference between
void A(const class1 a);
and
void A(const class1 &a);
in C++.
I am not able to differentiate these two.
what is the difference between
void A(const class1 a);
and
void A(const class1 &a);
in C++.
I am not able to differentiate these two.
 
    
     
    
    The main difference is that
A(const class1 a);
will create a local copy of a inside A which can be expensive (from both memory and computational point of view) while
A(const class1 &a);
will not create a copy.
Therefore passing the reference (2nd version) is usually the preferred way.
