Stel ik heb de volgende klasse:
Als ik dit compile in MSVC (2008) dan is het helemaal perfect en goed. Echter met GCC (4.4.1) krijg ik de volgende foutmelding:
WTF? Moet ik nou echt DERIVED(): BASE<int>(5) {} doen en overal de template specialisation van BASE doorgeven? Kan dit niet op een andere manier? Voor mijn eigen classes is dit niet zo'n heel groot probleem maar ik gebruik ook BOOST::spirit en daar is het echt een ramp om alles uit te schrijven.
C++:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
| template <class T> class BASE { public: BASE(int N) { _val = new T[N]; } private: T* _val; }; class DERIVED: public BASE<int> { public: DERIVED(): BASE(5) {} }; int main() { DERIVED a; return 0; } |
Als ik dit compile in MSVC (2008) dan is het helemaal perfect en goed. Echter met GCC (4.4.1) krijg ik de volgende foutmelding:
code:
1
2
3
4
5
| test.cpp: In constructor DERIVED::DERIVED(): test.cpp:12: error: class DERIVED does not have any field named BASE test.cpp:12: error: no matching function call to BASE<int>::BASE() test.cpp:3: note: candidates are: BASE<T>::BASE(int) [with T = int] test.cpp:1: note: BASE<int>BASE(const BASE<int>&) |
WTF? Moet ik nou echt DERIVED(): BASE<int>(5) {} doen en overal de template specialisation van BASE doorgeven? Kan dit niet op een andere manier? Voor mijn eigen classes is dit niet zo'n heel groot probleem maar ik gebruik ook BOOST::spirit en daar is het echt een ramp om alles uit te schrijven.
Windows Vista? *NEVER* Het waarom - Opera forever!!!
I've seen chickens that were more menacing. Chickens in a coma. On ice. In my fridge