Answers for "c++ over load operator"

C++
0

c++ over load operator

// This will substract one vector (math vector) from another
// Good example of how to use operator overloading

vec2 operator - (vec2 const &other) {
    return vec2(x - other.x, y - other.y);
}
Posted by: Guest on February-12-2021
-1

operator ++ overloading c++

class Point
{
public:
	Point& operator++() { ... }		// prefix
	Point operator++(int) { ... }	// postfix
  	friend Point& operator++(Point &p);			// friend prefix
  	friend Point operator++(Point &p, int);		// friend postfix
  	// in Microsoft Docs written "friend Point& operator++(Point &p, int);"
};
Posted by: Guest on August-15-2020

Browse Popular Code Answers by Language