home
C++ TUTORIALS

A BRIEF INTRODUCTION TO C++

What is C++?
C++ is a object oriented language.It was developed by BJARNE STROUSTRUP at AT&T BELL LABORATORIES in early 1980s.Object oriented language includes some features as:

Object oriented language


The characteristics of an object oriented language are:

DATA ABSTRACTION

The act of representing essential features without including the background details.

ENCAPSULATION

The wrapping of data and functions together in a single entity.

INHERITANCE

Inheritance is the process by which objects of one class acquires the properties of another class.

POLYMORPHISM

The ability to take more than one form.Eg:Operator and function overloading.

DYNAMIC BINDING

The linking of a procedure call to the code to be executed in response to the call.Also known as late binding means that code associated with a given procedure call is not known until the time of call at run time.


A SIMPLE C++ PROGRAM

       #include < iostream >     //include header file
       using namespace std;
       int main()
       { 
           cout<<"C++ IS OBJECT ORIENTED LANGUAGE\n";  //C++ STATEMENT
           return 0;
       }
       

PROGRAM FEATURES

The above example contains only main().Every C++ program must have a function main().COMMENTS start with double slash symbol and terminate at the end of the file.For multiple comments we use "/*". OUTPUT OPERATOR "cout" is an identifier which is a predefined object that represents the standard output stream in c++ with insertion operator "<<". WHILE "cin" is and object for input with extraction operator ">>".

THE IOSTREAM FILE

A C++ program typically contains pre processor directive statements at the beginning. Such statements are preceded with # symbol to indicate the presence of a pre-processor directive to the compiler which in turn lets the preprocessor handle the # directive symbol.

NAMESPACE

NAMESPACE is a new concept which defines a scope for the identifiers that are used in a program.In "using namespace std" where std is namespace where ANSI C++ standard class libraries are defines."using" & "namespace" are two new keywords.

RETURN TYPE OF main().

In c++,main() returns an integer type value to the operating system.It returns 0 means the program ran successfully.

ANOTHER EXAMPLE

		#include< iostream >
		using namespace std;
		
		int main()
		{
		  float n;   //variable
		  cin>>n;    //input         
	          return 0;
		 }
NOTE:iostream is within "<>" angle brackets.