include a functionality to overload stream extraction operator
Include a functionality to overload stream insertion operator
Overload power operator
#include using namespace std;class CVector { int x,y; public: CVector () {}; CVector (int,int); CVector operator + (CVector); void print();};void CVector::print(){ cout < ","=""><>}CVector::CVector (int x, int y) { this->x = x; this->y = y;}CVector CVector::operator+ (CVector param) { CVector temp; temp.x = this->x + param.x; temp.y = this->y + param.y; return temp;}int main () { CVector a (3,1); CVector b (4,9); CVector c; c = a.operator +(b); c.print(); return 0;}
using namespace std;
class CVector {
int x,y;
public:
CVector () {};
CVector (int,int);
CVector operator + (CVector);
void print();
};
void CVector::print()
{
cout < ","=""><>
}
CVector::CVector (int x, int y) {
this->x = x;
this->y = y;
CVector CVector::operator+ (CVector param) {
CVector temp;
temp.x = this->x + param.x;
temp.y = this->y + param.y;
return temp;
int main () {
CVector a (3,1);
CVector b (4,9);
CVector c;
c = a.operator +(b);
c.print();
return 0;
Already registered? Login
Not Account? Sign up
Enter your email address to reset your password
Back to Login? Click here