Possibili duplicati:
GCC problem : using a member of a base class that depends on a template argument
Why does GCC need extra declarations in templates when VS does not?
Why doesn’t a derived template class have access to a base template class
iphone compiler inherited templated base classes with passed through type not being expanded in time (just look)classe C++ Template eredita un'altra classe template con un tipo di input modello specificato
Ci scusiamo per il titolo di confusione, meglio che potrei inventare.
Ecco po 'di codice per illustrare il mio problema ...
una classe template di base:
template<class T> class TestBase
{
public:
int someInt;
};
Cercando di sottoclasse TestBase con un'altra classe template ...
Questo ottiene "someInt non è stato dichiarato in questo ambito" in fase di compilazione:
template<class X> class TestSub : public TestBase<X>
{
void testf()
{
someInt = 0; //Error: "someInt was not declared in this scope"
}
};
B) Ciò funziona benissimo (con la differenza che ho specificato input del modello di TestBase esplicitamente)
template<class X> class TestSub : public TestBase<string>
{
void testf()
{
someInt = 0;
}
};
Perchè TestSub da (A) non erediteranno someInt correttamente come in (B)?
Grazie in anticipo.
Chiuso come un duplicato di http://stackoverflow.com/questions/11405/gcc-problem-using-a-member-of-a-base-class-that-depends-on-a-template-argument e http://stackoverflow.com/questions/1643035/typedef-in-template-base-class e http://stackoverflow.com/questions/1239908/why-doesnt-a-ivedived-template-class-have-access- to-a-base-template-class e http://stackoverflow.com/questions/2812470/why-does-gcc-need-extra-declarations-in-templates-when-vs-does-not e molti altri –