Archived

This topic is now archived and is closed to further replies.

basic question

This topic is 5536 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

In the MSDN I read the following example:
    
int func( char );
int func( int );
void main ()
{
//   +func;       // error, can't resolve which func to use

   +func( 0 );  // OK

}
    
The first will generate an error as the comment states, but the second one compiles. Please tell me: what does that + sing mean in front of the function call? [edited by - xropi on October 18, 2002 9:22:35 AM]

Share this post


Link to post
Share on other sites
Compiler Error C2244
''identifier'' : unable to resolve function overload

for those who don''t know them off by heart (c;

no, i don''t know why they''ve got pluses in there

Share this post


Link to post
Share on other sites
If memory serves (I don''t have a compiler here at the moment to check), it should compile to "0 + func(0)".

The reason "+func(0)" is required instead of just "+func" is because adding zero to a char is just as valid as adding zero to an int, so you need to give the compiler more information about which function you''re referring to. ("+func(0)" refers to the int version. You''d need to cast the zero explicitly to a char to get the other function instead.)

At least, that''s what my memory tells me. It may be wrong; it''s been a while since I did much C++ coding.

--
Sean Timarco Baggaley

Share this post


Link to post
Share on other sites