Ik heb een kleine klasse geschreven, deze heeft alleen private vector in zich waar enkele public operaties voor beschikbaar zijn die ik geschreven heb.
Nu wil ik de '=' operator gebruiken, dit krijg ik niet voor elkaar...
in m 'n class header file heb ik staan:
mailItem is dus de naam van mijn klasse...
De implementatie in mijn cpp code:
element is hier de private vector.
Wat die ik fout??
berg compiler fouten:
Nu wil ik de '=' operator gebruiken, dit krijg ik niet voor elkaar...
in m 'n class header file heb ik staan:
C++:
1
| mailItem& operator = (const mailItem& param); |
mailItem is dus de naam van mijn klasse...
De implementatie in mijn cpp code:
C++:
1
2
3
4
| mailItem& operator = (const mailItem ¶m) { this.element = param.element; return *this; } |
element is hier de private vector.
Wat die ik fout??
berg compiler fouten:
code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
| mailItemClass.h:18: candidates are: mailItem& mailItem::operator=(const mailItem&) mailItemClass.cpp:27: `mailItem& operator=(const mailItem&)' must be a nonstatic member function mailItemClass.cpp:27: `mailItem& operator=(const mailItem&)' must take exactly two arguments mailItemClass.cpp: In function `mailItem& operator=(const mailItem&)': mailItemClass.cpp:33: `element' undeclared (first use this function) mailItemClass.cpp:33: (Each undeclared identifier is reported only once for each function it appears in.) mailItemClass.h:7: `std::vector<std::string, std::allocator<std::string> > mailItem::element' is private mailItemClass.cpp:33: within this context mailItemClass.cpp:34: invalid use of `this' in non-member function |