Name Mangling and Extern "C" in C++Both Java and C++ programming languages support method and function overloading, respectively. Function overloading is simply having more than one function, which is differentiated either by having differences in the number of arguments or by the difference in the data types passed as arguments or parameters. The real question is how the compiler of java and c++ programming languages differentiates one function from the other. The simple answer to a complex problem, the compiler adds more information from its end. It saves the methods or parameters to its stack memory during execution. The c++ compilers don't have any specific technique different from the others, and it uses the same name-mangling concept to solve the problem of function overloading. Function Overloading in C++ -1Output: The sum of two integer variables is= 222 The sum of the two double variables is= 121.5 Function Overloading in C++ -2Output: The sum of two integer variables is= 430 The sum of three integer variables is= 165 Function Overloading in C++ -3Output: Here we have the integer 100 Here we have the float 100.1 Here we have the character hundred Name Mangling and Extern 'C' in C++Demonstration code Output: /usr/bin/ld: cannot open output file a.out: Permission denied collect2: error: ld returned 1 exit status C++ codeOutput: /usr/bin/ld: cannot open output file a.out: Permission denied collect2: error: ld returned 1 exit status Extern COutput: javaTpoint Next TopicDIFFERENT COMPILERS FOR C++ |
We provides tutorials and interview questions of all technology like java tutorial, android, java frameworks
G-13, 2nd Floor, Sec-3, Noida, UP, 201301, India