BLOGGER TEMPLATES AND TWITTER BACKGROUNDS »

C++









  • Whats is C++ ?


C++ is a computer programming language created in 1983 by Bjarne Stroustrup and designed to serve as an enhanced version of the C language. It is object oriented and is considered a high level language. However, it features low level facilities. C++ is one of the most commonly used programming languages.
The development of C++ actually began four years before its release, in 1979. It did not start out with this name; its first name was "C with Classes." In the late part of 1983, C with Classes was first used for AT&T’s internal programming needs. Its name was changed to C++ later in the same year. The language was not released commercially until the late part of 1985.
Developed at Bell Labs, C++ enhanced the C programming language in a variety of ways. Among its features are classes, virtual functions, templates, and operator overloading. The language also counts multiple inheritance and exception handling among its many features. C++ introduced the use of declarations as statements and includes more type checking than is available with C.




  • How to execute the program :
Compile using DevC++ compiler
If you work on Windows and use DevC++, then editing and compiling is as easy as click of a button. DevC++ is an IDE which allows you to edit, compile, run and debug  your program in the IDE itself.

  1. Once you have installed and configured the software, Write and save your program using DevC++ itself. Create a new program by clicking on New à Project.
  2. Choose Empty Project from New Project dialog and choose a name for the program, in our case first and click Ok.
  3. Write the code of the program and save it.
  4. Click on Compile button (third row, first button) to compile your source code. If there are any errors in your program, then a window at the bottom will specify the warnings.
  5. After program is compiled, click on Run button (next to compile).
  6. However, DevC++ has a problem. As soon as you Run the program, output window opens momentarily and then it closes. So to come around this solution, set a breakpoint at the end of main function and then click on Debug instead of running it.
  7. When you run the program, output window will show the string.
Compile using VC++
If you use Visual C++ toolkit for C++ programming, then the procedure is same as in DevC++.



  • How to compilation process:
There are many C compilers around. The cc being the default Sun compiler. The GNU C compiler gcc is popular and available for many platforms. PC users may also be familiar with the Borland bcc compiler.
There are also equivalent C++ compilers which are usually denoted by CC (note upper case CC. For example Sun provides CC and GNU GCC. The GNU compiler is also denoted by g++
Other (less common) C/C++ compilers exist. All the above compilers operate in essentially the same manner and share many common command line options. Below and in Appendix [*] we list and give example uses many of the common compiler options. However, the best source of each compiler is through the online manual pages of your system: e.g. man cc.
For the sake of compactness in the basic discussions of compiler operation we will simply refer to the cc compiler -- other compilers can simply be substituted in place of cc unless otherwise stated.
To Compile your program simply invoke the command cc. The command must be followed by the name of the (C) program you wish to compile. A number of compiler options can be specified also. We will not concern ourselves with many of these options yet, some useful and often essential options are introduced below -- See Appendix [*] or online manual help for further details.
Thus, the basic compilation command is:
    cc program.c
where program.c is the name of the file.
If there are obvious errors in your program (such as mistypings, misspelling one of the key words or omitting a semi-colon), the compiler will detect and report them.
There may, of course, still be logical errors that the compiler cannot detect. You may be telling the computer to do the wrong operations.
When the compiler has successfully digested your program, the compiled version, or executable, is left in a file called a.out or if the compiler option -o is used : the file listed after the -o.
It is more convenient to use a -o and filename in the compilation as in
    cc -o program program.c
which puts the compiled program into the file program (or any file you name following the "-o" argument) instead of putting it in the file a.out .