Answer to Question #254817 in C++ for Rohit Swain

Question #254817

Write a program in C++, which demonstrate = operator overloading.


1
Expert's answer
2021-10-21T13:52:35-0400
struct Point {
	int x, y;
	Point& operator=(const Point& p) noexcept {
		x = p.x;
		y = p.y;
	}
};

int main() {
	Point a, b;
	a.x = 1;
	a.y = 1;
	b = a; // Point::operator=
	return 0;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS