Доброго времени суток.
Столкнулся с такой проблемой. "gcc" не воспринимает конструкцию:
template <class T> class classB : public classA< T> {
public:
...
T GetM1(void) { return m_t1; }
T GetM2(void) { return m_t2; }
};
$ g++ test.cpp
test.cpp: In member function ‘T classB<T>::GetM1()’:
test.cpp:15: error: ‘m_t1’ was not declared in this scope
test.cpp: In member function ‘T classB<T>::GetM2()’:
test.cpp:16: error: ‘m_t2’ was not declared in this scope
Код:
//
template <class T> class classA {
public:
T m_t1;
T m_t2;
}; // class classA
//
template <class T> class classB : public classA< T> {
public:
classB() {}
~classB() {}
public:
T GetM1(void) { return m_t1; }
T GetM2(void) { return m_t2; }
}; // class classB
//
int main(int argc, char **argv)
{
int retCode=0;
classB<int> regInt;
return retCode;
} // main()
/* EOF */
gcc version 4.0.0 20050519 (Red Hat 4.0.0-8)
Я проверил на VC++ - все работает.
Может я что то не знаю, подскажите, если не сложно.
Раньше я обходил такие штуки, не использовал наследование в шаблонах.
gcc не поддерживает наследование в шаблонах ?