parameter with no name

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

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++...???

Interesting.

What compiler?

Kuphryn

Share on other sites
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 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 on other sites
I've seen alot of function prototypes with nameless parameters, but not methods.

Learn something every day.

Dave

Share on other sites
Ok..it makes sense now.

1. 1
2. 2
3. 3
Rutin
22
4. 4
5. 5

• 12
• 19
• 14
• 9
• 9
• Forum Statistics

• Total Topics
632929
• Total Posts
3009285
• Who's Online (See full list)

There are no registered users currently online

×