I successfully created pre-increment operator member function. But post-increment is creating following error:
Below is my implementation of post-increment operator overloading member function:
/* Issue is in this member function */
Point& Point::operator++(int)
{
Point duplicate = *this; // This exact line fails to work
operator++();
return duplicate;
}
Pre-increment operator overloading member function:
Point& Point::operator++()
{
++this->x_coordinate;
++this->y_coordinate;
return *this;
}
As it says that there is “no suitable copy constructor”, here is my copy constructor code:
Point::Point(const Point& _point) : Point(_point.x_coordinate, _point.y_coordinate) {}
I have declared both the constructors as explicit
.
What is the issue here?
Did I ignore something or created something different?
Thank you for any assistance!
P.S. - I am using Visual Studio 2022