Created
May 19, 2015 14:53
-
-
Save MasazI/c7d1a9df6ba9c2bac14e to your computer and use it in GitHub Desktop.
namespace_op.cpp
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // | |
| // 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