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]
Other format: [Raw text]

Re: Problem when using template as the base class?



On 23 Sep, 2006, at 1:47, Peng Yu wrote:


I have the following program. It also includes the non-template
equivalent class, which works fine. If you uncomment the comments, you
will see the compiler errors. The errors are also shown below. Do you
know what is wrong? Is it a bug of the compiler?


BTW, I use g++-3.4.

I corrected the error by adding template keyword. But I don't understand why "template" keyword is need. Would you please help me?

Because when the compiler first parses your function, it doesn't know what type T is, and so it cannot know that 'T::(something).as' is a template and 'T::(something)/as<int>' is valid syntax.


This is standard C++, go google up 'templates two-phase name lookup'.

Daniel.


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