I have a very small c++ program that consists of two files: main.cpp and something.cpp. I'd like to compile my program using g++ in the OS X Terminal. Here's what I've tried:
> g++ main.cpp something.cpp
> ./a.out
Is this correct? I've come across examples that use the -o flag. I'm not sure if that's necessary.
Does it work? That's a pretty good indication of correctness! The -o flag allows you to specify a file name so the executable is not named a.out
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With