|
C++ is an object oriented programming language. It was developed by Bjarne Stroustrup at AT&T Bell Laboratories in 1980's. C++ is a super set of C. Most of what we already know about C applies to C++ also. Almost all programs are also C++ programs. However, there are a few minor differences that will prevent a C Program to run under C++ compiler. The most important facilities that C++ adds on to C are classes, inheritance, function overloading, and operator overloading. These features enable to creating of abstract data types, inherit properties from existing data types and support polymorphism, thereby making C++ truly object oriented language.
The object oriented feature in C++ allow programmers to build large programs with clarity, extensibility and ease of maintenance, incorporating the spirit and efficiency of C. The addition of new features has transformed C from a language that currently facilitates top-down, structured design, to one that provided bottom-up, object-oriented design.
Application of C++
C++ is a versatile language for handling very large programs. It is suitable for virtually any programming task including development of editors, compilers, databases, communication systems and any complex real life application systems.
Why C++ is better then C
The designers of C++ wanted to add object-oriented mechanisms without compromising the efficiency and simplicity that made C so popular. One of the driving principles for the language designers was to hide complexity from the programmer, allowing her to concentrate on the problem at hand.
Because C++ retains C as a subset, it gains many of the attractive features of the C language, such as efficiency, closeness to the machine, and a variety of built-in types. A number of new features were added to C++ to make the language even more robust, many of which are not used by novice programmers. By introducing these new features here, we hope that you will begin to use them in your own programs early on and gain their benefits. Some of the features we will look at are the role of constants, inline expansion, references, declaration statements, user defined types, overloading, and the free store.
Most of these features can be summarized by two important design goals: strong compiler type checking and a user-extensible language.
By enforcing stricter type-checking, the C++ compiler makes us acutely aware of data types in our expressions. Stronger type checking is provided through several mechanisms, including: function argument type checking, conversions.
C++ also enables programmers to incorporate new types into the language, through the use of classes. A class is a user-defined type. The compiler can treat new types as if they are one of the built-in types. This is a very powerful feature. In addition, the class provides the mechanism for data abstraction and encapsulation, which are key to object-oriented programming.
A Simple C++ program
| #include<iostream.h>
using namespace snt;
main()
{
cout<<" This is first program of C++";
return 0;
}
|
In the above example contains only one function, main(). The execution begin at main(). Every C++ program must have a main().
|