Talk About Network



Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > C++ > Default functio...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 1 of 7 Topic 45808 of 45898
Post > Topic >>

Default function parameter values

by Tim Frink <plfriko@[EMAIL PROTECTED] > May 8, 2008 at 12:16 PM

Hi,

how can I set default values to template parameters?

I've this code:

class A
{
   template<typename T>
   void foo( string = "", T* = 0, bool (T::*func)(void) = 0 );
};

when I invoke A::foo with the appropriate 3 parameters, everything
works fine. However, I'd like to invoke the function foo also
with the first parameter, like objectA.foo( string("test") );
When I try to compile, I get the error message:
"no matching function for A::foo(std::string)".

Why? I set the second and third parameter of foo to default values,
so when the second and third argument are not specified, they should
be set to 0. But this seems not to work that way.

Tim




 7 Posts in Topic:
Default function parameter values
Tim Frink <plfriko@[EM  2008-05-08 12:16:07 
Re: Default function parameter values
"Victor Bazarov"  2008-05-08 08:25:23 
Re: Default function parameter values
Andrey Tarasevich <and  2008-05-08 17:20:50 
Re: Default function parameter values
Tim Frink <plfriko@[EM  2008-05-08 13:10:36 
Re: Default function parameter values
"Victor Bazarov"  2008-05-08 10:00:16 
Re: Default function parameter values
Andrey Tarasevich <and  2008-05-08 17:32:08 
Re: Default function parameter values
Tim Frink <plfriko@[EM  2008-05-09 10:13:17 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Wed May 14 19:10:09 CDT 2008.