Skip to content

Instantly share code, notes, and snippets.

@MasazI
Created May 19, 2015 14:53
Show Gist options
  • Select an option

  • Save MasazI/c7d1a9df6ba9c2bac14e to your computer and use it in GitHub Desktop.

Select an option

Save MasazI/c7d1a9df6ba9c2bac14e to your computer and use it in GitHub Desktop.
namespace_op.cpp
//
// namespace_operator.cpp
// CplusplusPractice
//
// Created by masai on 2015/05/19.
// Copyright (c) 2015年 masai. All rights reserved.
//
#include <iostream>
namespace namespace_op {
class Integer {
int value;
public:
int operator + (Integer obj) {
// biasの30が必ずプラスされるオペレータ+
return this->value + obj.value + 30;
}
Integer(int value) { this->value = value; }
};
}
using namespace namespace_op;
int main() {
Integer obj1(10) , obj2(100);
std::cout << obj1 + obj2 << std::endl;
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment