This is the mail archive of the gcc-bugs@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 with templates (is this correct code?)


>         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


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