The Concept Bundled together in one object Data Types Functionality Encapsulation State variables used to describe the object Functions dictating how the object interacts and interfaces with other entities ID: 931444
Download Presentation The PPT/PDF document "Object-Oriented Paradigm" is the property of its rightful owner. Permission is granted to download and print the materials on this web site for personal, non-commercial use only, and to display it on your personal computer provided you do not modify the materials and that you retain all copyright notices contained in the materials. By downloading content from our website, you accept the terms of this agreement.
Slide1
Object-Oriented Paradigm
Slide2The Concept
Bundled together in one object
Data Types
Functionality
Encapsulation
State variables used to describe the object
Functions dictating how the object interacts and interfaces with other entities
Slide3Your First Class
class
name_of_type
{
public:
// function prototypes here
private:
// member data here
};
Slide4Your First Class
class
name_of_type
{
public:
// function prototypes here
private:
// member data here
};
class Fraction
{
public:
void
readin
();
void print();
Fraction reciprocal();
void unreduced(const
int
m);
private:
int
m_Numerator
;
int
m_Denominator
;
};
Slide5Your First Class
class
name_of_type
{
public:
// function prototypes here
private:
// member data here
};
class Fraction
{
public:
void
readin
();
void print();
Fraction reciprocal();
void unreduced(const
int
m);
private:
int
m_Numerator
;
int
m_Denominator
;
};
Slide6Your First Class
class
name_of_type
{
public:
// function prototypes here
private:
// member data here
};
class Fraction
{
public:
void
readin
();
void print();
Fraction reciprocal();
void unreduced(const
int
m);
private:
int
m_Numerator
;
int
m_Denominator
;
};
Slide7Your First Class
class
name_of_type
{
public:
// function prototypes here
private:
// member data here
};
class Fraction
{
public:
void
readin
();
void print();
Fraction reciprocal();
void unreduced(const
int
m);
private:
int
m_Numerator
;
int
m_Denominator
;
};
Slide8Your First Class
class
name_of_type
{
public:
// function prototypes here
private:
// member data here
};
class Fraction
{
public:
void
readin
();
void print();
Fraction reciprocal();
void unreduced(const
int
m);
private:
int
m_Numerator
;
int
m_Denominator
;
};
Slide9Your First Class
class
name_of_type
{
public:
// function prototypes here
private:
// member data here
};
class Fraction
{
public:
void
readin
();
void print();
Fraction reciprocal();
void unreduced(const
int
m);
private:
int
m_Numerator
;
int
m_Denominator
;
};
Slide10Private By Default
class Fraction
{
public:
void
readin
();
void print();
Fraction reciprocal();
void unreduced(const
int
m);
private:
int
m_Numerator
;
int
m_Denominator
;
};
class Fraction
{
int
m_Numerator
;
int
m_Denominator
;
public:
void
readin
();
void print();
Fraction reciprocal();
void unreduced(const
int
m);
};
Slide11Private By Default
class Fraction
{
public:
void
readin
();
void print();
Fraction reciprocal();
void unreduced(const
int
m);
private:
int
m_Numerator
;
int
m_Denominator
;
};
class Fraction
{
int
m_Numerator
;
int
m_Denominator
;
public:
void
readin
();
void print();
Fraction reciprocal();
void unreduced(const
int
m);
};
Slide12Definition and Use
//
fraction.h
#
ifndef
FRACTION_H
#define FRACTION_H
class Fraction
{
public:
void
readin
();
void print();
Fraction reciprocal();
void unreduced(const
int
m);
private:
int
m_Numerator
;
int
m_Denominator
;
};
#
endif
#include
“
fraction.h
”
int
main()
{
Fraction f, g;
f.m_Numerator
= 7;
f.readin
();
f.print
();
f.unreduce
(5);
return 0;
}
Slide13Definition and Use
//
fraction.h
#
ifndef
FRACTION_H
#define FRACTION_H
class Fraction
{
public:
void
readin
();
void print();
Fraction reciprocal();
void unreduced(const
int
m);
private:
int
m_Numerator
;
int
m_Denominator
;
};
#
endif
#include
“
fraction.h
”
int
main()
{
Fraction f, g;
f.m_Numerator
= 7;
f.readin
();
f.print
(); f.unreduce(5); return 0;}
Slide14Definition and Use
//
fraction.h
#
ifndef
FRACTION_H
#define FRACTION_H
class Fraction
{
public:
void
readin
();
void print();
Fraction reciprocal();
void unreduced(const
int
m);
private:
int
m_Numerator
;
int
m_Denominator
;
};
#
endif
#include
“
fraction.h
”
int
main()
{
Fraction f, g;
f.m_Numerator
= 7;
f.readin
();
f.print
(); f.unreduce(5); return 0;}
//
won’t compile!
Slide15Definition and Use
//
fraction.h
#
ifndef
FRACTION_H
#define FRACTION_H
class Fraction
{
public:
void
readin
();
void print();
Fraction reciprocal();
void unreduced(const
int
m);
private:
int
m_Numerator
;
int
m_Denominator
;
};
#
endif
#include
“
fraction.h
”
int
main()
{
Fraction f, g;
f.m_Numerator
= 7;
f.readin
();
f.print
(); f.unreduce(5); return 0;}
Slide16Definition and Use
//
fraction.h
#
ifndef
FRACTION_H
#define FRACTION_H
class Fraction
{
public:
void
readin
();
void print();
Fraction reciprocal();
void unreduced(const
int
m);
private:
int
m_Numerator
;
int
m_Denominator
;
};
#
endif
#include
“
fraction.h
”
int
main()
{
Fraction f, g;
f.m_Numerator
= 7;
f.readin
();
f.print
(); f.unreduce(5); return 0;}
Slide17Definition and Use
//
fraction.h
#
ifndef
FRACTION_H
#define FRACTION_H
class Fraction
{
public:
void
readin
();
void print();
Fraction reciprocal();
void unreduced(const
int
m);
private:
int
m_Numerator
;
int
m_Denominator
;
};
#
endif
#include
“
fraction.h
”
int
main()
{
Fraction f, g;
f.m_Numerator
= 7;
f.readin
();
f.print
(); f.unreduce(5); return 0;}
Slide18End of Session