Make sure the file is named *.cpp, so C::B knows it's a c++-file and uses the correct compiler.
There are several other things missing from your source and it will not compile (even not with a c++-compiler), but that is basic c++-stuff and questions like this are not allowed in our forum/on our website.
Please read a good book about beginners programming in c++ (or a tutorial) or ask in a c++-forum.
Otherwise you violate our forum rules and your topic will most likely become locked.