# Overloading Unary Operator in "Point" Class

**URL:** <https://forum.codewithmosh.com/t/overloading-unary-operator-in-point-class/20400>\
**Category:** C++\
**Created:** [May 22, 2023, 5:15pm UTC](https://forum.codewithmosh.com/t/overloading-unary-operator-in-point-class/20400 "2023-05-22T17:15:41Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![POMPOMBALLS](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.codewithmosh.com/pompomballs/32/6610_2.png) [@POMPOMBALLS](https://forum.codewithmosh.com/u/POMPOMBALLS)\
**Post date:** [May 22, 2023, 5:15pm UTC](https://forum.codewithmosh.com/t/overloading-unary-operator-in-point-class/20400/1 "2023-05-22T17:15:41Z")

</div>

I successfully created pre-increment operator member function. But post-increment is creating following error:

 ![image](https://us1.discourse-cdn.com/flex020/uploads/codewithmosh/original/2X/1/148df809709a6c5359f365b26724fdaac7d93222.png)

Below is my implementation of post-increment operator overloading member function:

```auto
/* 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:

```auto
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:

```auto
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_
