Thursday, April 9, 2009

INTRODUCTION TO C++

INTRODUCTION OF C++

C++ is an Object Oriented Programming language. C++ was developed by Bjarne Stroustrup at AT & T Bell Laboratories Murray Hill, New Jersey, USA, in the early eighties (1982). Using C language we can solve simple problems to solve complex problem he decided to develop a new language that will support real world problems. So he took Object and Class from Simlua 67 (Simlua 67 is first object oriented language) and entire C language syntax. Merging these two concepts (C++ is an extension of C with a major addition of the class construct feature of simula67) he developed a new language. It is initially called a c with classes later it was renamed as C++. So C++ is a superset of C. Therefore. Almost all C programs are also C++ programs. The object oriented features in C++ allow programmers to build large programs with clarity, extensibility and ease of maintenance.

Sample C++ Program

// comment Statement

#include

#include

main()

{

cout<<"God";

}

Output will be

God


Main()
The C++ program is a collection of functions. Every C++ program must have a main()
Comment Statemen

Two type of comments are there
1. Single line comments
2. Multi line comments
C++ introduces a new comment symbol // (Double slash).
Single line comments
Double slash comment is basically a single line comment. Start with double slash symbol and terminate at the end of the line. A comment may start anywhere in the line and whatever follows till the end of the line is ignored. Note that there is no closing symbol.

Single line comments can be written as follows:
//cout<<”Good Morning”; //cout<<”Good Afternoon”; //cout<<”Good Evening”; //cout<<”Good Night”;

Multi Line comments

The comment symbols /*, */ are still valid and are more suitable for multi line comments. Multi line comments can be written as follows:

/* cout<<”Good Morning”; cout<<”Good Afternoon”; cout<<”Good Evening”; cout<<”Good Night”; */

Example

For example, the double slash comment cannot be used in the following case:

for (j=0; j

No comments:

Post a Comment