File: default_methods.cpp

package info (click to toggle)
clazy 1.16-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 5,384 kB
  • sloc: cpp: 24,969; python: 1,429; xml: 448; sh: 237; makefile: 48
file content (53 lines) | stat: -rw-r--r-- 837 bytes parent folder | download | duplicates (2)
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
47
48
49
50
51
52
53
#include <cstdio>

struct Color
{
    unsigned int r;
    unsigned int g;
    unsigned int b;
    unsigned int opacity;

    Color &operator=(const Color &c) = default;
    bool operator==(const Color &c) const = default;
    Color(const Color &c) = default;
    Color() = default;
};
struct Color2
{
    unsigned int r;
    unsigned int g;
    unsigned int b;
    unsigned int opacity;

    Color2 &operator=(const Color2 &c) {
        r=c.r;
        g=c.g;
        b=c.b;
        opacity =c.opacity;
        return *this;
    }
    bool operator==(const Color2 &c) const {
        return c.b == b;
    }
};

int main()
{
    Color c;
    c.r = 3;

    Color c2;
    c2 = c;

    Color c3(c2);


    Color2 otherType;
    Color2 otherType2;

    otherType2 = otherType;

    printf("C2.r %d\n", c2.r);
    printf("C3.r %d\n", c3.r);
}