I dont know how to compile cpp programs with gcc as i am new to gcc
and cpp.
could anybody help me out?
If you use the correct filename extensions on your source files, then
the 'gcc' command will happily compile your C++ code. There is one
caveat -- if you make use of any StdLib functions, you will need to
tell 'gcc' to use the C++ library instead of defaulting to the C one.
From the 'man' page:
" Compiling C++ Programs
C++ source files conventionally use one of the suffixes .C,
..cc, .cpp,.CPP, .c++, .cp, or .cxx; C++ header files often use .hh
or .H; and preprocessed C++ files use the suffix .ii. GCC
recognizes files with these names and compiles them as C++ programs
even if you call the com$B!>(Bpiler the same way as for compiling C
programs (usually with the name gcc).
However, C++ programs often require class libraries as well as
a compiler that understands the C++ language---and under some
circumstances, you might want to compile programs or header files from
standard input, or otherwise without a suffix that flags them as C++
programs. You might also like to precompile a C header file with a .h
extension to be used in C++ compilations. g++ is a program that calls
GCC with the default language set to C++, and automatically specifies
linking against the C++ library. On many systems, g++ is also
installed with the name c++."
Nathan.