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 33 34 35 36 37 38 39 40 41 42 43 44 45 46
|
#include <iostream>
#include <utility>
#include "../../typetrait/typetrait"
#include "../binops"
class Demo
{
friend std::ostream &operator<<(std::ostream &out, Demo const &demo);
int d_value;
public:
Demo(int value = 0)
:
d_value(value)
{}
Demo(Demo const &other)
:
d_value(other.d_value)
{
std::cout << "Demo CC called\n";
}
Demo &operator+=(Demo const &rhs)
{
d_value += rhs.d_value;
return *this;
}
};
std::ostream &operator<<(std::ostream &out, Demo const &demo)
{
return out << demo.d_value;
}
using namespace std;
int main()
{
Demo four(4);
Demo five(5);
cout << four + five << '\n' <<
four + 5 << '\n' <<
4 + five << '\n';
}
|