• Advertisement
Sign in to follow this  

parameter with no name

This topic is 4345 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

Today i came across a code which had paramters with no name
void func(int){}

It gave an error in C but worked in C++...???

Share this post


Link to post
Share on other sites
Advertisement
well was there a prototpye of it before that code? Cuz it should work then. Im betting thats what it is. The definition probably just says int x or whatever, since functions are named by > name of the function, param_type, ..etc

Share this post


Link to post
Share on other sites
There's nothing wrong with not naming the parameter in the parameter list. You just won't have access to it. This is commonly done with arguments in overridden virtual functions which aren't going to be used, because the compiler usually won't issue an "argument not referenced" warning if the argument isn't named.

Share this post


Link to post
Share on other sites
I've seen alot of function prototypes with nameless parameters, but not methods.

Learn something every day.

Dave

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement