Avatar ·

What is the difference between g++ and gcc when compiling C++ code?

Hello everyone! I just started learning C++ and compile my programs through the terminal. Previously, I wrote in C and used the gcc command for compilation. Now that I've switched to C++, I noticed that many tutorials use g++ instead of gcc. I tried compiling a simple C++ code with gcc, and it gave errors. For example, here's my code:
#include <iostream>
int main() {
    std::cout << "Hello, world!" << std::endl;
    return 0;
}
When I run `gcc test.cpp -o test`, I get a bunch of linking errors, like `undefined reference to std::cout`. But if I run `g++ test.cpp -o test`, everything works fine. What is the difference here? Are they just different versions of the same compiler? Or do they do something fundamentally different? Do I need to