Hoi ik krijg vreemde foutmeldingen in mijn code. Ik heb een standaard control, waar andere zelf te maken controls van afgeleid kunnen worden.
De klasse heet BASIC_CONTROL
in de .h file heb ik ze als volgt gedeclareerd:
in m'n .cpp file include ik de .h file uiteraard en worden ze als volgt geimplementeerd:
in de .cpp file krijg ik echter de volgende foutmeldingen:
ik heb al van alles uitgeprobeerd, maar echt gericht zoeken kon ik niet, aangezien dit binnen mijn kennisgebied gewoon zou moeten werken, iemand enig idee wat er mis zou kunnen zijn. bvd.
De klasse heet BASIC_CONTROL
in de .h file heb ik ze als volgt gedeclareerd:
C++:
1
2
3
4
| public: friend bool operator == ( const BASIC_CONTROL& a, const BASIC_CONTROL& b ); friend bool operator != ( const BASIC_CONTROL& a, const BASIC_CONTROL& b ); BASIC_CONTROL& operator = ( const BASIC_CONTROL& a ); |
in m'n .cpp file include ik de .h file uiteraard en worden ze als volgt geimplementeerd:
C++:
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
| bool operator == ( const BASIC_CONTROL& a, const BASIC_CONTROL& b ) { if ( ( a.hwnd == b.hwnd ) && // Compare the window handle ( a.hinst == b.hinst ) && // Compare the instance handle ( a.name == b.name ) && // Compare the name ( a.winproc == b.winproc ) && // Compare the window proc ( a.x == b.x ) && // Compare the x coordinate ( a.y == b.y ) && // Compare the y coordinate ( a.width == b.width ) && // Compare the width ( a.height == b.height ) ) // Compare the height { return true; // Two identical controls } else { return false; // Control a and b differ } } bool operator != ( const BASIC_CONTROL& a, const BASIC_CONTROL& b ) { return !( a == b ); // Return !( a == b ) } BASIC_CONTROL& BASIC_CONTROL :: operator = ( const BASIC_CONTROL& a ) { this->hwnd = a.hwnd; // Assign the window handle this->hinst = a.hinst; // Assign the instance handle this->name = a.name; // Assign the name this->winproc = a.winproc; // Assign the window proc this->x = a.x; // Assign the x coordinate this->y = a.y; // Assign the y coordinate this->width = a.width; // Assign the width this->height = a.height; // Assign the height return *this; // Assign it to the operand } |
in de .cpp file krijg ik echter de volgende foutmeldingen:
C++:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
| regel 2: Warning : function has no prototype regel 3 t/m 10: Error : illegal access from 'BASIC_CONTROL' to protected/private member 'BASIC_CONTROL::hwnd' regel 21: Warning : function has no prototype BASIC_CONTROL.cpp line 71 { regel 22: Error : function call 'operator ==({lval} const BASIC_CONTROL, {lval} const BASIC_CONTROL)' is ambiguous 'PMI::operator ==(const BASIC_CONTROL &, const BASIC_CONTROL &)' 'operator ==(const BASIC_CONTROL &, const BASIC_CONTROL &)' BASIC_CONTROL.cpp line 72 return !( a == b ); // Return !( a == b ) |
ik heb al van alles uitgeprobeerd, maar echt gericht zoeken kon ik niet, aangezien dit binnen mijn kennisgebied gewoon zou moeten werken, iemand enig idee wat er mis zou kunnen zijn. bvd.
[ Voor 6% gewijzigd door Krooswijk.com op 22-05-2003 13:59 ]