Function overloading and return type
Function overloading and return type
For example, the following program C++ and Java programs fail in compilation.
C++ Program
int DESCRIBE() { return 10; }char DESCRIBE() { // compiler error; new declaration of DESCRIBE() return 'a'; }int main(){ char x = DESCRIBE(); getchar(); return 0;} |
Java Program
// filename Main.javapublic class Main { public int DESCRIBE() { return 10; } public char DESCRIBE() { // compiler error: DESCRIBE() is already defined return 'a'; } public static void main(String args[]) { }} |
Comments
Post a Comment