vico
vico

Reputation: 18171

Syntax Type Name(Type) in function

I found in sample code strange syntax. I have no idea what this code does, but looks nothing. What does syntax type Name(Type) in function means?

void doJob()
{
...
bool SetForward(bool); //strange line
...
}

Upvotes: 0

Views: 52

Answers (2)

Bilal Wasim
Bilal Wasim

Reputation: 17

Function Declarations are usually done at the top of your program so that the main can access all of them !! However , what if you want your main not able to access that function ? You simply declare its prototype in the function which is going to use it !! Another Example can be seen a private function in a class which can only be accessed by class methods & not by the main program !!

Upvotes: 0

molbdnilo
molbdnilo

Reputation: 66371

It's a function declaration.

They don't have to be at file scope, but it's fairly rare to see them inside functions if you're not reading relatively ancient C code.

Upvotes: 1

Related Questions