OOPM UNIT 1 (Cse)
OOPM UNIT 1 (Cse)
Object A Object B
Data Data
Communication
Functions Functions
Object C
Data
Functions
Benefits of object-oriented techno-
logy include:
Ease of software design
Productivity
Easy testing, debugging, and maintenance
It’s reusable
More thorough data analysis, less development time,
and more accurate coding, thanks to OOP’s inheritance
method
Data is safe and secure, with less data corruption,
thanks to hiding and abstraction.
It’s sharable (classes are reusable and can be distributed
to other networks).
Procedure Oriented Programming (Pop) & Object-Oriented
Programming (Oop)
centre radius
circumference()
area()
A class describes an
object
OBJECT
HAS DOES
color bounce
diameter roll
brand
properties behav-
ior
Prof.Deepak Gaikar
a class describes an
Class ball object
String color; Float
diameter; String
brand;
OBJECT
void bounce(float h)
void roll (float d)
HAS DOES
properties behavior
Prof.Deepak Gaikar
Circle ball
Teacher (specialization,exp,qualification)
Teach(),read(),write() explain()
Class teacher
{
Char name[20];
Int exp;
Void display()
{ name=“hasnain”;
Exp=6;
}
};
Void main()
{
Teacher t1;
t1.display();
The two keywords cout in C++ and cin
in C++ are used very often for printing
outputs and taking inputs respectively.
These two are the most basic methods of
taking input and printing output in C++.
To use cin and cout in C++ one must in-
clude the header file iostream in the pro-
gram.
Standard output stream (cout):
Usually the standard output device is the
display screen. The C++ cout statement is
the instance of the ostream class. It is used
to produce output on the standard output
device which is usually the display screen.
The data needed to be displayed on the
screen is inserted in the standard output
stream (cout) using the insertion
operator(<<).
Standard input stream (cin):
Usually the input device in a computer is
the keyboard. C++ cin statement is the in-
stance of the class istream and is used to
read input from the standard input device
which is usually a keyboard.
The extraction operator(>>) is used along
with the object cin for reading inputs. The
extraction operator extracts the data from
the object cin which is entered using the
keyboard.
Un-buffered standard error
stream (cerr):
The C++ cerr is the standard error stream that is used to
output the errors. This is also an instance of the ostream
class. As cerr in C++ is un-buffered so it is used when
one needs to display the error message immediately. It
does not have any buffer to store the error message and
display it later.
The main difference between cerr and cout comes when
we would like to redirect output using “cout” that gets
redirected to file if you use “cerr” the error doesn’t get
stored in file.(This is what un-buffered means ..It cant
store the message)
Variable Declaration in C++