Ik heb een prachtige object hierarchie gebouwd, waarin ik een operator heb gedefinieerd. (in het voorbeeld de operator =).
Hoe kan ik nu de parent aanroepen (die een ANDERE parametertype heeft...)
Hoe kan ik nu de parent aanroepen (die een ANDERE parametertype heeft...)
code:
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
| class Parent
{
public:
Parent();
const Parent& operator=(const Parent &right);
};
class Child
{
public:
Child();
const Child& operator=(const Child &right);
};
Parent::Parent()
{
cout << "Parent constructed" << endl;
}
Child::Child()
:
Parent();
{
cout << "Childconstructed" << endl;
}
const Parent& Parent::operator=(const Parent &right)
{
cout << "Parent operator..." << endl;
}
const Child & Child::operator=(const Child &right)
{
// eerst parent aanroepen. right als Parent...
// de code zou zijn:
// *object = *right
// maar dan roept 'ie deze procedure aan...
cout << "Child operator..." << endl;
} |
Localhost, sweet localhost