This file contains 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; | |
} | |
0 件のコメント:
コメントを投稿