1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 | #include <iostream> #include<string> using namespace std; class Vector { public: int x,y; Vector () {}; Vector (int a,int b) { x=a; y=b; } Vector operator+(const Vector&); }; Vector Vector::operator+(const Vector& parameter){ Vector temp; temp.x=x+ parameter.x; temp.y=y+ parameter.y; return temp; } int main() { Vector vec1(4,2); Vector vec2(2,2); Vector result; result=vec1+vec2; cout<<"the result is ("<<result.x<<","<<result.y<<")"<<endl; int x=2,y=3; int z=x+y; return 0; } |
-------------------------------------------------------------------
Verwandte Suchanfragen zu operator overloading in c++
overloading ostream operator c++
c++ cast operator overloading
overloading assignment operator c++
overloading increment operator c++
c++ operator overloading wiki
c++ virtual operator overloading
c++ operator overloading example
C++ Operator Overloading Guidelines
C++ Overloading (Operator and Function)
C++ Operator Overloading
C++ Overloading and Operator Overloading
Searches related to c++ tutorials
c++ tutorials pdf
c++ examples
c++ video tutorials
dev c++ tutorials
visual c++ tutorials for beginners
advanced c++ tutorials
visual c++ tutorials
c++ tutorials youtube
C++ Programming/Operators/Operator Overloading
c++ operator+=