As others pointed out, the line
void func();
inside main considered as a function prototype, not a func function call. In C and C ++, you can declare function prototypes inside functions if you want, although this is rarely done in practice.
The fact that this is legal causes all kinds of headaches for programmers. For example, if you rewrote the code as
(void) func();
This will then compile as a call to func , whose return type is explicitly indicated by void to indicate "I don't care about the return value." In other words, this set of parentheses changes the declaration into an operator.
In C ++, this problem can be compounded by the fact that this code below is a function prototype, and not a variable declaration that calls the default constructor:
Object myObject();
Although
Object myObject(137);
creates an object and passes 137 to its constructor, and
Object myObject;
creates an object without calling the constructor.
There is a terrible regional case of the language called the โmost unpleasant analysisโ that occurs when you try to declare an object when you call its constructor. For example, this code is legal C ++, but it is a function declaration, not a variable declaration:
set<int> mySet(istream_iterator<int>(cin), istream_iterator<int>());
The problem is that this can be parsed as a function declaration, rather than creating an object that takes two istream_iterator<int> time parameters. To fix this, in C ++ you need to write
set<int> mySet(istream_iterator<int>(cin), (istream_iterator<int>()));
Where, as indicated above, additional parentheses forcefully eliminate the inconsistency of the operator as a prototype of the function as the declaration.
Hope this helps!