File: driver.cc

package info (click to toggle)
bobcat 3.01.00-1
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 6,612 kB
  • sloc: cpp: 12,107; makefile: 8,055; perl: 401; sh: 329
file content (46 lines) | stat: -rw-r--r-- 842 bytes parent folder | download | duplicates (5)
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';
}