example:
Point (const Point &p2)
{
x=p2.x;
y=p2.y;
}
Why we have used the term const while writing a copy constructor
Hi Gaurav, we use const in copy constructor to avoid the accidental modification of the objects. It ensures that you don’t accidentally damage the original when making the copy. The object passed in should not be modified by the function.
2 Likes
thanks alot …