It would be easier to help you if you explain a little more about what you're trying to do.
If you want to compile a small, single file, C++ program in a file called test.cpp, you can use the Terminal command g++ like so:
g++ test.cpp -o test
Then you can execute it like so:
./test