Re: Problem when using template as the base class?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




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 of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux