Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- class Pareja {
- public:
- double a, b;
- bool operator > (const Pareja& other) const;
- Pareja& operator = (const Pareja& other) {
- if (*this == other) return *this;
- a = other.a;
- b = other.b;
- return *this;
- }
- operator int() const {
- return (int)(a+b);
- }
- Pareja operator +(const Pareja& other) const{
- Pareja temp = *this;
- temp.a += other.a;
- temp.b += other.b;
- return temp;
- }
- Pareja operator -(const Pareja& other) const{
- Pareja temp = *this;
- temp.a -= other.a;
- temp.b -= other.b;
- return temp;
- }
- Pareja operator *(const Pareja& other) const{
- Pareja temp = *this;
- temp.a -= other.a;
- temp.b -= other.b;
- return temp;
- }
- //Prefix:
- Pareja& operator ++(void) {
- ++a;
- ++b;
- return *this;
- }
- //Posfix
- Pareja operator ++(int) {
- Pareja temp = *this;
- a++;
- b++;
- return temp;
- }
- // Shift left
- Pareja operator <<(unsigned int shift) const{
- Pareja temp = *this;
- temp.a = (int)temp.a << shift;
- temp.b = (int)temp.b << shift;
- return temp;
- }
- // Shift right
- Pareja operator >>(unsigned int shift){
- Pareja temp = *this;
- temp.a = (int)temp.a >> shift;
- temp.b = (int)temp.b >> shift;
- return temp;
- }
- friend ostream& operator << (ostream& o, const Pareja& p);
- friend istream& operator >> (istream& i, const Pareja& p);
- };
- ostream& operator << (ostream& o, const Pareja& p){
- o << "( " << p.a << " , " << p.b << " )";
- return o;
- }
- istream& operator >> (istream& i, const Pareja& p){
- // Sarasa
- return i;
- }
- int main(){
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment