This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
Re: Problem with templates (is this correct code?)
- To: massacre at quake2 dot nettally dot com
- Subject: Re: Problem with templates (is this correct code?)
- From: "Martin v. Loewis" <martin at mira dot isdn dot cs dot tu-berlin dot de>
- Date: Wed, 8 Sep 1999 08:11:14 +0200
- CC: gcc-bugs at gcc dot gnu dot org
- References: <Pine.LNX.4.04.9909072054150.13836-100000@quake2.nettally.com>
> int lookup(const classType);
[...]
> typedef test<char *> mytest;
[...]
> mytest *foo=new mytest();
> const char * bar="this should work, right?";
> foo->lookup(bar);
> I seem to be having a problem getting my template to recognize
> adding a 'const' keyword to a function.
This code is incorrect. The signature of lookup is
int mytest::lookup(char * const);
I.e. the pointer is const, not the char. You can't pass a char const *
to lookup.
Hope this helps,
Martin