As per the comments, when compiling C++, you need to use the correct compiler. clang++
for C++.
Often the C and C++ compilers are the same basic program, but invoking them as eg. clang or clang++ invokes them with the correct options for the target language.
Most likely the errors you saw were the result of the program not being linked against the correct runtime libraries.