aboutsummaryrefslogtreecommitdiffstats
path: root/tests/libsample/derived.cpp
blob: 9a86a9c94664a5a35920da0fa9dc99651a83733b (plain)
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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
#include <iostream>
#include "derived.h"

using namespace std;

Derived::Derived(int id) : Abstract(id)
{
    cout << __PRETTY_FUNCTION__;
    show();
    cout << endl;
}

Derived::~Derived()
{
    cout << __PRETTY_FUNCTION__;
    show();
    cout << endl;
}

Abstract*
Derived::createObject()
{
    static int id = 100;
    return new Derived(id++);
}

void
Derived::pureVirtual()
{
    cout << __PRETTY_FUNCTION__ << endl;
}

void
Derived::unpureVirtual()
{
    cout << __PRETTY_FUNCTION__ << endl;
}

bool
Derived::singleArgument(bool b)
{
    cout << __PRETTY_FUNCTION__ << endl;
    return !b;
}

double
Derived::defaultValue(int n)
{
    cout << __PRETTY_FUNCTION__ << "[n = 0]" << endl;
    return ((double) n) + 0.1;
}

PolymorphicFuncEnum
Derived::polymorphic(int i, int d)
{
    cout << __PRETTY_FUNCTION__ << "[i = 0, d = 0]" << endl;
    return PolymorphicFunc_ii;
}

PolymorphicFuncEnum
Derived::polymorphic(double n)
{
    cout << __PRETTY_FUNCTION__ << endl;
    return PolymorphicFunc_d;
}

Derived::OtherPolymorphicFuncEnum
Derived::otherPolymorphic(int a, int b, bool c, double d)
{
    cout << __PRETTY_FUNCTION__ << endl;
    return OtherPolymorphicFunc_iibd;
}

Derived::OtherPolymorphicFuncEnum
Derived::otherPolymorphic(int a, double b)
{
    cout << __PRETTY_FUNCTION__ << endl;
    return OtherPolymorphicFunc_id;
}