0% found this document useful (0 votes)
6 views17 pages

Unit 1

The document provides an overview of Object-Oriented Programming (OOP) principles and the evolution of programming languages, highlighting the transition from procedural to object-oriented paradigms. It discusses key concepts of OOP such as classes, objects, encapsulation, inheritance, and polymorphism, along with the advantages of using OOP in software development. Additionally, it covers the usage of C++ for input/output operations and the differences between C and C++ I/O functions.

Uploaded by

Malar P
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views17 pages

Unit 1

The document provides an overview of Object-Oriented Programming (OOP) principles and the evolution of programming languages, highlighting the transition from procedural to object-oriented paradigms. It discusses key concepts of OOP such as classes, objects, encapsulation, inheritance, and polymorphism, along with the advantages of using OOP in software development. Additionally, it covers the usage of C++ for input/output operations and the differences between C and C++ I/O functions.

Uploaded by

Malar P
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd

PROGRAMMING IN C++

UNIT – I

Principles of Object Oriented Programming [OOP]:

EVOLUTION OF C++

In first generation computers, the binary languages were used for programming

As the technology improved, computers were widely used in many fields. Their speed and memory were increased.
In order to meet the larger requirements, the assembly languages were introduced. This is used in second-generation
computers.

For third generation computers, assembly languages were not enough to use because it is not easy to modify larger
programs. For this, third generation languages were introduced. FORTRAN, COBOL, PASCAL, ALGOL, C AND
BASIC are some of the third generation languages. They are also known as procedure oriented languages.

When the size of the program increases the complexity of program architecture also increases. Here a new style of
programming structure is required to incorporate good program structures that are easy to understand, implement
and modify.

Keeping all the above things in mind software engineers working all around the world constantly improved the
program construction so that the programming job becomes easy, error free and easy to understand.

The fourth generation computers are using non-procedural languages such as RDBMS, OOP (Object Oriented
Programming).

In OOP, attempt is made to avoid some of the drawbacks of procedural languages. They incorporate new features.
So that the real world problem can be easily modeled and the solution can be easily implemented.

PROGRAMMING PARADIGMS

Conventional programming using high level languages such as FORTRAN, COBOL, C, PASCAL and
BASIC is called as “Procedure Oriented Programming”.

In Procedure Oriented Programming, the given problem is viewed as sequence of operations such as getting
input, calculating, printing, decision making and looping. A program in these languages consists of a set of
statements.

For small programs the above organizing principle or paradigm as it is called is sufficient. The programmer
writes a list of statements, and the computer carriers them out.

In order to carry out the large task, the solution is broken down into number of functions. Some times it is
required to define group of global variables that are used by group of functions. But there are chances that the
global variables may be accidentally accessed and modified by other function also.

The situation where the global data can be accessed and modified by any function can be schematically
represented as in the following figure

1
In the above figure, there is no restriction for any function to access and modify global data. Data is not
protected in this situation

In object Oriented approach, the set of functions and the set of global variables that are manipulated by
these functions are bundled together. This avoids other functions to access these variables. This construct is called
as a class. Data are accessed only through member functions.

It is clear that in Procedure Oriented Programming more importance is given to function, how function is to
be called, what sequence to be used, what logic is to be used etc. Less importance is given to data.

In Object Oriented Programming more importance is given to data. Data is the vital part in a program. It
should be secured properly. Unauthorized functions should not touch the data. Here it is possible to change the
attribute through its member functions only. Hence data is safe. More security is given to data. Without knowing
the function it is not possible to change the data.

What is Object – Oriented Programming?

Object-oriented programming language is a feature that allows a mode of modularizing programs by


forming separate memory area for data as well as functions that is used as object for making copies of modules as
per requirement.

KEY CONCEPTS OF OOP

Explain the basic or key concepts of Object Oriented Programming.

There are several fundamental or key concepts in object-oriented programming. They are discussed below:

1. OBJECTS

Objects are primary run-time entities in an object-oriented programming.

An Object is the entity in the program that imitates the attributes and behavior of the real world items such
as a person, book detail, a place, group of marks, a bank account, a picture or any other items that the program has
to process.

An object is a group of related functions and data that serves those functions.

An object is a kind of a self-sufficient “subprogram” with a specific functional area.

The selected program objects must be similar to actual world objects. Objects occupy space in memory.
Every object has its own properties or features.

An object is a specimen of a class. In C++ the class variables are known as objects.

2. CLASS

The most important feature of C++ is the “Class”.


A class is grouping of objects having identical properties, common
Class: Computer
behavior, and shared relationship

2
Properties: brand, price, monitor resolution, hard disk and RAM size

Actions: processing( ), display( ) and printing( )

A class is a new way of creating and implementing a user defined data type. Classes provide a method for packing
together data of different types.

For Example:

class student
{
char name[30];
int rllno, mark1, mark2, total_mark;
}
In other words

A class is a way to bind the data and its associated functions together.

3. METHODS OR MEMBER FUNCTIONS

An operation required for an object or entity when coded in a class is called a


method

In C++ Member functions are called as methods.

Member functions are the functions that perform specific tasks in a class.

4. DATA ENCAPSULATION

The packing of data and functions into a single component (called class) is known as
encapsulation.

C++ supports the features of encapsulation using classes.

The packing of data and functions into a single component (called class) is known as encapsulation. Data
encapsulation is the most important feature of a class. The data is not accessible by outside functions. Only those
functions that are able to access the data are defined within the class.

The members and functions declared under private are not accessible by members outside the class, this is
called data hiding.

5. DATA ABSTRACTION

Abstraction refers to the act of representing essential features without including


the background details or explanations.
3
Data abstraction is the ability to create user-defined data type for modeling real world objects using built-in
data types and a set of permitted operators.

Classes use the concept of abstraction and are defined as a list of abstract attributes such as size, weight and
cost, and functions to operate on these attributes. The attributes are sometimes called data members because they
hold information.

For example: A computer is made of various parts such as cpu, keyboard and son. We think it as a single
unit, but it has several sub units. These units when combined together perform the required task. By assembling
subparts we can make a single system.

6. INHERITANCE

Inheritance is the method by which objects of one class get the properties of objects of
another class

Inheritance is the most powerful feature of an object oriented programming language. It is a process of creating new
classes called derived classes, form the existing or base classes. The derived class inherits all the properties of the
base class.

7. POLYMORPHISM

The word Polymorphism means many forms (poly-many, morph-shapes).

In C++, polymorphism is achieved through function overloading and operator overloading.

8. DYNAMIC BINDING

Binding means connecting one program to another program that is to be executed in reply to the call.

9. MESSAGE PASSING

Object-Oriented Programming includes objects which communicate with each other. Data is transferred
from one object to another.

10. REUSABILITY OF THE CODE

Object-Oriented technology allows reusability of the classes by extending them to other classes using
inheritance.

Once a class is defined, the other programmer can also use it in their programs and add new features in the derived
classes. Thus, reusability saves time.

11. DELEGATION

In OOP, two classes can be joined either by – inheritance or delegation, which provide reusability of the
class.

4
12. GENERICITY

The software components of a program have move than one version depending on the data types of
arguments. This feature allows declaration of variables without specifying exact data type. The compiler identifies
the data type at run time.

ADVANTAGES OF OOP

List out the Advantages of Object Oriented Programming

Object-oriented programming provides many advantages to the programmer and the user. This technology solves
many problems related to software development, provides improved quality, and low cost software. OOP has the
following advantages:

 Objected – oriented programs can be comfortably upgraded


 Using inheritance, redundant program codes can be eliminated and the use of previously defined classes
may be continued.
 The technology of data hiding facilitates the programmer to design and develop safe programs that do not
disturb code in other parts of the program.
 Inheritance saves time
 User defined data types can be easily constructed
 Data security is enforced
 Software complexity can be easily managed
 The encapsulation feature provided by OOP languages allows programmer to define the class with many
functions and characteristics and only few functions are exposed to the user.
 All object-oriented programming languages can create extended and reusable parts of programs.
 Object-oriented programming enhances the thought process of a programmer leading to rapid development
of new software in short span of time.

USAGE OF OOP AND C++

USAGE OF OOP / APPLICATION OF OPP

Object-Oriented technology is changing the style of software engineers to think, analyze, plan, and
implement the software. The software developed using OOP technology is more efficient and easy to update. OOP
languages have standard class library. The users can reuse the standard class library in their program. Thus, it saves
lot of time and coding work.

The most popular application of object-oriented programming is windows. There are several windowing
software based on OOP technology.

Following are the areas for which OOP is considered:

1. Object – Oriented DBMS


2. Office automation software
3. Artificial Intelligence and expert systems
5
4. CAD – Computer Aided Design and manufacturing systems
5. Network programming
6. System software
7. Client – Server computing
8. Real time systems, such as process control, temperature control

USAGE OF C++

C++ is a flexible language. Lengthy programs can be easily controlled by the use of C++. It creates hierarchy –
associated objects and libraries that can be useful to other programmers. C++ helps the programmer to write bug-
free program, which are easy to maintain.

INPUT AND OUTPUT IN C++

Applications generally involve reading a large amount of data from input devices and sending them to the
output devices. Hence to control such operations every language provides a set of in-built functions. C++ supports
all Input / Output functions of C.

C++ also has library functions. A library is nothing but a set of .obj files. It is connected to the user’s
program. A programmer can use the library functions in the programs.

STREAMS IN C++

C++ supports a number of Input/Output (I/O) operations to read and write operations. These C++ I/O
functions make it possible for the user to work with different types of devices such as keyboard, disk, tape drivers
etc.

The stream is an intermediator between I/O devices and the user. The standard C++ library contains the I/O
stream functions.

Stream is flow of data in bytes in sequence. If data is received form output devices in sequence then it is
called as source stream and when the data is passed to output devices then it is called as destination stream. The
data is received from keyboard or disk and can be passed on to monitor or to the disk.

STREAM CLASSES

C++ streams are based on class and object theory. C++ has a number of stream classes that are used to work
with console and file operations. These classes are known as stream classes. All these classes are declared in the
header file iostream.h. The file iostream.h must be included in the program if we are using functions of these
classes.

The classes istream and ostream are derived classes of base class ios. The ios class has an ability to handle
formatted and unformatted I/O operations.

UNFORMATED CONSOLE I/O OPERTAIONS

Input and Output Streams

The input stream uses cin object to read data and the output stream uses cout object to display data on the
screen. The cin and cout are predefined streams for input and output of data. The data type is identified by these
functions using operator overloading of the operators << (insertion operator) and >> (extraction operator).
6
The operator << is overloaded in the ostream class and the opertator >> is overloaded in istream class.

INPUT STREAM

Input stream represents the flow of data from the standard input device – the keyboard. It uses cin as object.

The cin statement is used to read data through the input device (key board) during run time.

The declarations for the object cin are available in a header file called as istream.h

The cin statement uses >> (extraction operator) before variable name.

Syntax:

cin>>variable

Example:

int v1;
float v2;
char v3;

cin>>v1>>v2>v3….>>vn;

where v1, v2 and v3 are variable names. The response of the user to this statement would be as per given below

2 5.4 A // input data

If the user enters data in the manner 2 5.4 A, the operator will assign 2 to v1, 5.4 to v2 and A to v3.

The entered data is separated by space, tab, or enter. Like scanf( ) statement cin does not require control strings like
%d for integer, %f for float and so on.

More than one variable can be used in cin statement to input data. Such operations are known as cascaded input
operations.

More examples:

int weight;
cin>>weight; // Reads integer value

float height;
cin>>height; // Reads float value

double volume;
cin>>volume // Reads double value

char result[10];
cin>>result; // Reads char string
7
OUTPUT STREAM

The output stream manages output of the stream i.e., displays contents of variables on the screen. It uses<<
insertion operator before variable name. It uses the cout object to perform console write operation.

Syntax:

cout<<variable

Example
cout<<v1<<v2<<v3….<<vn
where v1, v2, and v3 are variables. The above statement displays the contents of these variables on the screen. The
syntax rules are same as cin.

The cout statement does not use the format specification like %d, %f, as used in c, and so on.

The cout statement allows us to use all ‘C’ escape sequences like ‘\n’, ‘\t’, and so on.

More examples:

int weight;
cout<<weight; // Displays integer value

float height;
cout<<height; // Displays float value

double volume;
cout<<volume // Displays double value

char result[10];
cout<<result; // Displays char string

DIFFERENCE IN USING C AND C++ I/O FUNCTIONS

The printf( ) and scanf( ) of C language need format string. For example, to read and display integer, the scanf( )
and printf( ) statements can be written as follows:

int x;
scanf(“%d”, &x)
printf(“%d”, x)

In the above statement %d is used to tell the I/O functions to treat the data as integer.

If the integer x is changed to long integer the programmer needs to change every occurrence of %d in the program
with %ld.

The C++ statement reads and displays the same data as follows

8
int x;
cin>>x;
cout<<x;

Here, the cin and cout statements do not require any format string. If the type of x is changed to long
integer, the user won’t need to specify the type of data or any correction in the statement. The format of cin and
cout statement is same for all types of variables.

get ( ) and put ( ) function

get ( )

The single character input and output operations in C++ can be done with the help of get ( ) and put ( ) functions.
The class istream and ostream provides the two member functions put ( ) and get ( ). The get ( ) is used to read a
character and put ( ) is used to display the character on the screen.

The get ( ) has two syntaxes

get (char*);
get (void);

If the syntax (a) is used, the get ( ) function assigns the read data to its argument, whereas if syntax (b) is
used, the get ( ) function returns the data read. The data is assigned to the variable present at left-hand side of the
assignment operator. These functions are members of I/O stream classes and can be called using object.

put ( )
The put ( ) function is used to display the string on the screen. It is a member of iostream class.

The syntax of put( ) is given below

[Link](‘A’)
[Link](x);

The statement (a) displays the character ‘A’ on the screen and the statement (b) displays the contents of
variable x on the screen. If an integer is used as an argument, its corresponding ASCII value is displayed.

Few examples are illustrated below:

Write a program to display the character on the screen using put( ) function

#include<iostream.h>
#include<conio.h>
void main()
{
clrscr( );
[Link](‘C’);
[Link](‘+’);
[Link](‘+’);
}

OUTPUT
C++

9
Explanation: The [Link]( ) statement displays one character at a time on the screen. In this program three
characters are displayed on the screen using [Link]( ) statement.
Write a program to use multiple put( ) statement with single cout object and display the
characters.

#include<iostream.h>
#include<conio.h>
void main()
{
clrscr( );
[Link](‘C’).put(‘+’).put(‘+’);
}

OUTPUT
C++

Explanation: In the above program, the single object cout is used followed by sequence of put ( ) statement. The
put ( ) statements are separated by dot operators. In this way multiple statements can be combined.

Write a program to read character using get ( ) and display it using put ( )

#include<iostream.h>
#include<conio.h>
void main()
{
char ch;
clrscr( );
cout<< “\n Enter a character :”;
[Link](ch);
cout<< “\n Entered character was :”;
[Link](ch);
}

OUTPUT
Enter a character: C

Entered character was: C

Explanation: In the above program, character variable ch is declared. The first cout statement displays message
“Enter a character:” on the screen. The [Link]( ) function activates input stream and character entered by the user is
stored in the variable ch. The [Link]( ) statement displays the character on the screen.
Write a program to read characters using sequence of get( ) statement and display
read characters using sequence of put( ) statement.

#include<iostream.h>
#include<conio.h>
void main( )
{
char ch[3];
clrscr( );
cout<< “\n Enter characters :”;

[Link](ch[0]).get(ch[1]).get(ch[2]);

cout<< “\n Characters Entered :”;


[Link](ch[0]).put(ch[1]).put(ch[2]);
}
10
OUTPUT
Enter a character: cpp

Entered character was: cpp


Explanation: In the above program, a character array ch[3] is declared. The sequence of get( ) and put( ) functions
are used to read and display the characters. The get( ) function reads characters and stores in array ch[3]. The put( )
function displays the same on the screen.

MEMBER FUNCTIONS OF ISTREAM CLASS

The istream contains following functions that can be called using cin object.

Peek( ): It returns the succeeding characters without extraction.

Example: [Link]( ) = = ‘#’;

Wherein cin is an object and ‘#’ is a symbol to be caught in the stream.

Ignore( ): The member function ignore ( ) has two arguments, maximum number of characters to avoid, and the
termination character.

Example: [Link](1, ‘#’);

The statement ignores 1 character till ‘#’ character is found

Write a program to demonstrate the use of peek( ) and ignore ( ) functions.

#include<iostream.h>
#include<conio.h>
void main( )
{
char c;
clrscr( );
cout<< “Enter text (press F6 to end:)”;

while([Link](c))
{
cout<<c;

while([Link]( )= = ‘#’)
{
[Link](1, ‘#’);
}

}
return 0;
}

OUTPUT
Enter text (press F6 to end:) ABCDEFG###HIJK ^Z
ABCDEFGHIJK

Explanation: In the above program, the [Link]( ) function continuously reads characters through the keyboard till
the user presses F6. The cout statement inside the loop displays the contents of variable c on the console. The
[Link]( ) statement checks the variable c. The variable c containing ‘#’ is ignored from the stream and not
displayed on the screen.

11
MANIPULATORS

What is manipulators? Explain the manipulators with an example?

The output formats can be controlled using manipulators. The header file iomanip.h has a set of functions. Effect of
these manipulators is the same as ios class member functions. Every ios member function has two formats. One is
used for setting and second format is used to know the previous setting. But the manipulator does not return to the
previous setting. The manipulator can be used with cout( ) statement as given below.

cout<<m1<<m2<<v1;

Here m1 and m2 are two manipulators and v1 is any valid C++ variable.
Table given below describes the most useful manipulators. The manipulator hex, dec, oct, ws, endl, and flush are
defined in iostream.h. The manipulator setbase, width( ), fill( ) etc. that requires an argument are defined in
iomanip.h
Pre-defined manipulators

MANIPULATOR FUNCTION
setw(int n) The field width is fixed to n
setbase Sets the base of the number system
setprecision (int p) The precision point is fixed to p
setfill( char f) The fill character is set to character stored in variablef
setiosglags(long l) Format flag is set to 1
resetiosflags(long 1) Removes the flags indicated by 1
Endl Splits a new line
Skipws Omits white space on input
noskipws Does not omit white space on input
Ends Adds null character to close an output string
Flush Flushes the buffer stream
Lock Locks the file associated with the file handle
Ws Used to omit the leading white spaces present before the first field
hex, oct, dec Displays the number in hexadecimal, octal, and decimal format

Write a program to display formatted output using manipulators

#include<iostream.h>
#include<iomanip.h>
#include<conio.h>
main( )
{
clrscr();
cout<<setw(10)<< “Hellow”<<endl;
cout<<setw(15)<<setprecision(2)<<2.5555;
cout<<setiosflags(ios::hex);
cout<<endl<< “Hexadecimal of 84 is: “<<84;

return 0;
}

OUTPUT

Hello
2.56
Hexadecimal of 84 is: 54
12
Explanation: In the above program, the manipulator setw(10) sets the field width to 10. The message “hello” is
displayed at column 10. The endl inserts a new line. In the second cout( ) statement. The setprecision(2)
manipulator sets the decimal point to 2. The number 2.5555 will be displayed as 2.56 at column 15. The
manipulator setiosflag sets the hexadecimal setting for the display of number. The last cout( ) statement displays the
equivalent hexadecimal of 84 i.e., 54.

Write a program to display the given decimal number in hexadecimal and octal format

#include<iostream.h>
#include<conio.h>
#include<iomanip.h>

void main( )
{
clrscr( );
int x=84;
cout<< “\n Hexa-decimal Number : “<<hex<<x;
cout<< “\n Octal Number : “<<oct<<x;
}

OUTPUT

Hexadecimal Number: 54
Octal Number : 124

Explanation: In the above program, the integer variable x is declared and initialized with 84. The first cout
statement displays the decimal number to its equivalent hexadecimal number. The manipulator hex converts
decimal number to its hexadecimal equivalent. The second cout statement converts decimal number to its
equivalent octal number.

Write a program to read number in hexadecimal format using cin statement. Display the number
in decimal format.

#include<iostream.h>
#include<conio.h>
void main( )
{
clrscr( );
int x;
cout<< “\n Enter Hexa-decimal Number:”;
cin>>hex>>x;
cout<< “\n Decimal Number :”<<dec<<x;
}

OUTPUT

Enter Hexadecimal Number: 31

Decimal Number : 25

Explanation: In the above program, the cin statement reads a number in hex format. The cout statement displays its
equivalent decimal number with the use of dec manipulator.

13
Write a program to demonstrate the use of endl manipulator
Explanation: In the above program, endl manipulator is used to split the line. The two strings are displayed on two
#include<iostream.h>
separate lines.
#include<conio.h>

void main( )
{
clrscr( );
cout<< “Demo of endl”;
endl(cout);
cout<< “ It splits a line”;
}

OUTPUT

Demo of endl
It splits a line

Write a program to demonstrate the use of flush( ) statement

#include<iostream.h>
#include<conio.h>

void main( )
{
char text[20];

Explanation: In the above program, the statement flush(cout) flushes the buffer. This statement can be used as
cout<<flush.

USER-DEFINED MANIPULATORS

The programmer can also define his/her own manipulator according to the requirements of the program. The
syntax for defining manipulator is given below:

ostream & m_name(ostream & o)


{
statement1;
statement2;
return o;
}

The m_name is the name of the manipulator

14
Write a program to create manipulator equivalent to ‘\t’. Use it in the program and format the
output.
#include<iostream.h>
#include<iomanip.h>
#include<conio.h>
ostream & tab(ostream & o)
{
o<<"\t";
return o;
Explanation:
} In the above program, tab named manipulator is defined. The definition
void main()
{
clrscr();
cout<<1<<tab<<2<<tab<<3;

getch();
}
OUTPUT

1 2 3

of tab manipulator contains the escape sequence ‘\t’. Whenever we call the tab manipulator, the ‘\t’ is executed and we get the
effect of tab.

MANIPULATOR WITH ONE PARAMETER

The prototype declared in the iomanip.h as described earlier allows us to define individual set of macros. The
manipulator can be created without the use of int or long arguments.

Write a program with one parameter to display the string in the middle of the line

#include<iostream.h>
#include<iomanip.h>
#include<string.h>
#include<conio.h>
ostream& fc (ostream& ost, int iw)
{
for(int k=0; k<((75-iw)/2); k++)
ost<< “ “;
return (ost);
}
OMANIP (int) middle (int iw)
{
return OMANIP (int) (fc, iw);
}
int main( )
{
clrscr();
char *m=” * Well come *”;
cout<<middle (strlen(m))<<m;
Explanation: In the above program middle is a user-defined parameterized manipulator. It receives a value strlen(m) i.e.,
string length. The header file IOMANIO.H defines a macro, OMANIO (int). It is expanded to class_OMANIP_int. Due to this
the definition consists of a constructor and an overloaded ostream insertion operator. When middle( ) function is added into
the stream, it invokes the constructor which generates and returns an OMANIP_int object. The fc( ) function is called by the
object constructor.

MANIPULATORS WITH MULTIPLE PARAMETERS

15
In this type of manipulator, multiple arguments are passed on to the manipulator. The following program explains
it.

Write a program to create manipulator with two arguments

#include<iostream.h>
#include<conio.h>
#include<iomanip.h>
#include<math.h>
struct w_p
{
int w;
int p;
};
IOMANIPdeclare (w_p);
static ostream& ff(ostream& os, w_p w_p)
{
[Link] (w_p.w);
[Link](w_p.p);
[Link](ios::fixed);
return os;
}
OMANIP (w_p) column (int w, int p)
{
w_p w_p;
w_p.w=w;
w_p.p=p;
return OMANIP (w_p) (ff, w_p);
}
int main( )
{
clrscr( );
double n, sq, sqr;
cout<< “number \t” << “square \t”<< “\tsquare root\n”;
cout<< “===============================\n”;
n=1.0;

for (int j=1; j<16; j++)


{
sq=n*n;
sqr=sqrt(n);
[Link](‘0’);
cout<<column(3,0)<<n<<”\t”;
cout<<column(7,1)<<sq<<”\t\t”;
cout<<column(7,6)<<sqr<<endl;
n=n+1.0;
}
return 0;
}
OUTPUT
Number square square root
=============================
001 0000001 0000001
002 0000004 1.414214
003 0000009 1.732051
004 0000016 0000002
005 0000025 2.236068
006 0000036 2.44949
007 0000049 2.645751
008 0000064 2.828427
009 0000081 0000003 16
010 0000100 3.162278
011 0000121 3.316625
Explanation: The above program is same s the previous one. The only difference is that here two parameters are
used. The user-defined manipulator is assigned two integer values. The first argument decides the number of spaces
and the second argument decides number of decimal places. After initializing the w_p structure, constructor is
called. The constructor creates and return a_OMANIP object.

OBJECT – ORIENTED LANGUAGES

There are many languages which support object-oriented programming Table given below describe the OOP languages and
their features

Following object-oriented languages are widely accepted by the programmer:

C++
Java
Smalltalk
Charm ++

17

You might also like