Get Website Learn Coding Tech Story

C++ Programming Examples

What is C++?

C++ is a general-purpose programming language with a bias toward systems programming. It was developed by Bjarne Stroustrup at AT&T Bell Laboratories in Murray Hill, New Jersey, USA, in the early 1980's. Stroustrup, an admirer of Simula67 and a strong supporter of C, wanted to combine the best of both language and create a more powerful language that could support object-oriented programming features and still retain the power and elegance of C. The result is C++.

C++ is a superset of C. Most of known part of the C can be apply to C++. Therefore, almost all C programs are also C++ programs. However, there are a few minor differences that will prevent a C program to run under C++ compiler.

C++ is a versatile object oriented programming language for handling very large programs. It is suitable for virtually any programming task including development of editors, compilers, database, communication system and any complex real-life application systems.

How to Compile C++ program in Linux?

Use any one of the following syntax to compile the program called hello-world.cpp

g++ hello-world.cpp

On GNU systems, this results in the creation of an executable program with the default name a.out. To tell the compiler what the executable program to be called, use the -o option for setting the name of the object code.

g++ hello-world.cpp -o hello-world

How to run executable file in Linux?

For default executable file


For the specified executable file