




















Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
it's about object-oriented, it will help you to know the basics of OOP
Typology: Slides
1 / 28
This page cannot be seen from the preview
Don't miss anything!





















Structural (Procedural) Object-Oriented
FUNCTION
FUNCTION
FUNCTION
OBJECT
Operations
Data
OBJECT
Operations
Data
OBJECT
Operations
Data
Function calls Messages passing
handling unexpected inputs that are not explicitly defined
for its application.
of software to run with minimal change on different
hardware and operating system platforms.
of different systems in various applications.
Review: Object-Oriented
Programming Language Features
structured
array struct union class
address
pointer reference
Simple buit-in
integral enum
char short int long bool
Short x = 1;
floating
float double long double
4000
class Rectangle
{
private:
int width;
int length;
public:
void set(int w, int l);
int area();
};
Classes & Objects
Rectangle r1;
Rectangle r2;
Rectangle r3;
int a;
Define a Class Type
class class_name
permission_label:
member ;
permission_label:
member ;
class Rectangle
{
private:
int width;
int length;
public:
void set(int w, int l);
int area();
};
Body
Header
Static Data Member
Rectangle r1;
Rectangle r2;
Rectangle r3;
Cout<< r1.count;
Cout<<Rectangle::count;
width
length
width
length
width
length
r
r
r
count
Class Definition – Member
Functions(methods)
class ( mutator methods or setters or set or modifier
methods).
declaring a function
outside the class body
operator
i
class String{
private :
char * s;
public:
int length() const { int i=0 ; for(; s[i];i++); return i; }
char* copy(string & dest, const string & src) {
char* temp = new char[-----];
for(; i< src.length() ; i++)
return temp;
}};
Void main(){
String s,t;
char* p = s.copy(s,t);
temp
p
17
( function call outside of the class, but need to be with the name of it’s
class.
class Rectangle{
private:
double width, length;
static int count;
public:
Rectangle(double w=0, double l=0){
width = w; length= I;
count++;
}
inline double area() const { return width*length; }
static int getCount(){
return count; }
};
Class Definition – static member functions
Const Member Function
class Time
{
private :
int hrs, mins, secs ;
public :
void Write ( ) const;
void Write ( ) ;
} ;
void Time :: Write( ) const
{
cout <<hrs << “:” << mins << “:” << secs << endl;
}
function declaration
function definition
20
access from outside the class
friends of this class, not open for nonmember functions
C++
the default access specifier is private in classes
the default access specifier is public in structs
Class Definition - Access Control