Brauche Hilfe bei Fehler ...
-
Hi,
folgende Konstruktion, etwas vereinfacht aus meiner Programmarchitektur extrahiert:
template <class T> class C_Base { ... }; template <typename T> class C_1 : public T, C_Base<T> { public: C_1(const T& t) : T(t) {} }; template <class T, template <class> class TT> class R { typedef C_1<T> TYPE1; typedef TT<T> TYPE2; public: virtual TYPE2 operator() (const TYPE1& t) const {return TYPE2(t);} };Instantiieren in main.cpp:
R<int,C_1> test;führt zu folgendem Fehler:
..Test.h:41:
instantiated from TT<T> R<T, TT>::operator()(const C_1<T>&) const
[with T = int, TT = C_1]
main.cpp:66: instantiated from here
..Test.h:5: error: base type int fails to be a struct or class typemake: *** [main.o] Error 1
die angemeckerte Zeile 5 ist die Zeile 8 in obigem listing


deklariert man operator() als nicht virtuell klappt es
... ich brauch s aber mit virtuellem ()-operator. 
Falls jemand einen guten Tip hat, vielen Dank!
-
Du hast in R<int, ...> ein C_1<int> und diese klasse hat als grundtyp einen int.
Also steht nach der auflösung bei C_1 da:
[cpp]
class C_1 : public int, C_Base<int>
{
...
}
[/cpp]
Und, dass man von int nicht ableiten kann müsste klar sein(Basistyp...)