Hi,
Please try to compile this code :
This simple source code compiles without any warning with Microsoft VC++6's compiler. With gcc 3.4.3 I get the errors :
test-gcc.cpp: In member function `virtual const G& Indexable<G>::i_th(int) const':
test-gcc.cpp:14: error: there are no arguments to `item' that depend on a template parameter, so a declaration of `item' must be available
test-gcc.cpp:14: error: (if you use `-fpermissive', G++ will accept your code, but allowing the use of an undeclared name is deprecated)
I can't understand why g++ is not happy with this code snippet. If you decomment the line in class Indexable(redeclaration of Table<G, int>::item()), then g++ can compile. What is going on?
--
Globos
Please try to compile this code :
Code:
template<class G, class H>
class Table
{
public:
virtual const G& item (const H& k) const = 0;
};
template<class G>
class Indexable : public Table<G, int>
{
public:
//virtual const G& item (const int& k) const = 0;
virtual const G& i_th (int i) const
{ return item (i); }
};
int main ()
{ return 0; }
This simple source code compiles without any warning with Microsoft VC++6's compiler. With gcc 3.4.3 I get the errors :
test-gcc.cpp: In member function `virtual const G& Indexable<G>::i_th(int) const':
test-gcc.cpp:14: error: there are no arguments to `item' that depend on a template parameter, so a declaration of `item' must be available
test-gcc.cpp:14: error: (if you use `-fpermissive', G++ will accept your code, but allowing the use of an undeclared name is deprecated)
I can't understand why g++ is not happy with this code snippet. If you decomment the line in class Indexable(redeclaration of Table<G, int>::item()), then g++ can compile. What is going on?
--
Globos