C++ Program:
#include<iostream>
int main(){
sayHello();
}
void sayHello(){
std::cout << "Hello\n";
}
Output:
main.cpp: In function 'int main()':
main.cpp:4:5: error: 'sayHello' was not declared in this scope
sayHello();
^~~~~~~~
Java Program:
public class Main
{
public static void main(String[] args) {
sayHello();
}
public static void sayHello(){
System.out.println("Hello");
}
}
Output:
Hello
Is it just because Java provides support to resolve any dependencies among functions during compilation but C++ does not. If yes, Is there a specific reason that C++ did not provide this feature?