This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: Problem declaring template class functions


On Wed, 19 Apr 2000, Ivan Martinez wrote:

> 	Hello all,
> 	I have a template class declared in a header file like this:
> 
> template <class Type>
> class ClassA
> {
>   ...
>   void Func1();
>   bool Func2(Type);
> }

You need a semi-colon at the end of your class decl.

> 
> 	Its functions are declared in a code file like this:
> 
> template <class Type>
> bool ClassA<Type>::Func1()
> {
>   ...
> }

hm? In your class decl, you have ClassA<>::Func1() declared as returing
  void. This def has Func1() returing bool. They need to match.

> template <class Type>
> bool ClassA<Type>::Func2(Type)
> {
>   ...
> }
> 
> 	Why when I try to call the functions I get a "undefined reference
> to..." error?. 

If I make the 2 fixes I pointed out above, gcc 2.95.2 compiles this code
  fine.


> Also KDevelop shows them as global functions.

Do not trust class browsers. Many of them seem to use grammars that date
  back to about 1987 or so.

I have used lots class browsers (including KDevelop's) and they all
  fall into 2 categories:

  (1) Those that have many, many bugs related to browsing templated code.

  (2) Those that are useless for browsing templated code.

> 	I address this question to this list because I heard GCC is a bit
> different to standard in this issues.

As far as I know, gcc is std compliant in this area. Most of gcc's bugs
  are in it's standard library.

This question should have been addressed to comp.lang.c++.moderated, or
  some simlar c++ forum.




Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]