You are on page 1of 7

WHAT IS C++?

C

++OOP (Adding OPP to C)

C++

1
C++ Introduction

• C ++ is an object oriented programming language.

• C ++ was developed by Bjarne Stroustrup at AT & T Bell lab, USA in early eighties.

• C ++ was developed from c and simula 67 language.

• C ++ was early called ‘C with classes’.


C++ Comments:

Single line comment //(double slash).


• Comments start with a double slash symbol and terminate at the end of line.
• A comment may start any where in the line and what ever follows till the end of line is
ignored by the compiler.
• Note that there is no closing symbol.
• Example: // c++ program

Multi line comments can be written as follows:


• Multi-line comments start with /* and ends with */.
• Any text between /* and */ will be ignored by the compiler
Output Operator:

• The identifier cout can be used to display individual characters, strings and even numbers.

• It is a predefined object that corresponds to the standard output stream.

• Stream just refers to a flow of data and the standard Output stream normally flows to the

screen display.

• The cout object properties are defined in iostream.h

• The insertion operator << also called the ‘put to’ operator directs the information on its

right to the object on its left.

Ex: cout <<”Hello, world”


Input Operator:

• The identifier cin can be used to get input from the user.

• It is a predefined object that corresponds to the standard input stream.

• The cin object properties are defined in iostream.h

• The extraction operator >> also called the ‘get from’ operator is used for input

• It extracts value from the keyboard and assigns it to the variable on its right.

Ex: cin>> num;


iostream:
• iostream stands for standard input-output stream. This header file contains definitions of
objects like
• cout - displays output to output device
• cin - accepts input from the user
• cerr - Writes to error stream
• clog -used for streaming logs
• wcerr - prints to error stream as wide character type
• wcin - accepts input in wide character type
• wclog - writes to log stream with wide character
• wcout - displays wide characters (Unicode) to screen
Return Statement:

• In C++ main ( ) returns an integer type value to the operating system.

• Therefore every main ( ) in C++ should end with a return (0) statement, otherwise a

warning or an error might occur.

You might also like