A C/C++ Function Call Puzzle?


We know that C and C++ are very much similar in different aspects. The C++ has additional object oriented feature in it, but most of the C programs can also be correct in C++. Here we will see one program related to function call, that can be run when it is written in C, but will not work in C++.

Example

 Live Demo

#include<stdio.h>
void myFunction() {
   printf("Function called\n");
}
int main() {
   myFunction();
   myFunction(2);
}

Output

Function called
Function called

This program will run in C and generates output, but when we want to compile in C++, it will return an error during compile time. It will say there are too many arguments are passed.

Updated on: 30-Jul-2019

155 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements