SlideShare a Scribd company logo
3
Most read
4
Most read
12
Most read
Encapsulation
(Information Hiding)
Speaker: Muhammad Hammad Waseem
m.hammad.wasim@gmail.com
Encapsulation
• “ to enclose in or as in a capsule ”
• The object-oriented meaning of encapsulation is
• to enclose related data, routines and definitions in a class capsule. This does not
necessarily mean hiding. (Mish)
• Encapsulation is the ‘bundling together’ of data and
behavior so that they are inseparable. (Mcgraw Hill)
Why Encapsulation called Information Hiding
• Encapsulation (also called information hiding) consists of separating
the external aspects of an object, from the internal implementation
details of the object, which are hidden from other objects.
• Encapsulation prevents a program from becoming to interdependent
that a small change has massive ripple effects.
• Encapsulation has ability to combine data structure and behavior in a
single entity makes encapsulation cleaner and more powerful than in
conventional languages that separate data structure and behavior.
Information Hiding
• Information Hiding: a module is characterized by the information it
hides from other modules, which are called its clients. The hidden
information remains a secret to the client modules. (Ghezzi et al)
• Information hiding is the principle that users of a software component
(such as a class) need to know only the essential details of how to
initialize and access the component, and do not need to know the
details of the implementation. (Budd)
What Encapsulation Provides in OO?
• The interface is the visible surface of the capsule.
• The interface describes the essential characteristics of objects of the class
which are visible to the exterior world.
• Interface data – which should be visible from outside/other class or method.
• The implementation is hidden in the capsule.
• The implementation hiding means that data can only be manipulated, that is
updated, within the class, but it does not mean hiding interface data.
• Implementation data – which should be hidden from outside/other class or
method.
General 3 Ways to Encapsulate
Data
Public Member Access Specifier
Private Member Access Specifier
Protected Member Access Specifier
Public Member Access Specifier
• Syntax
• public: <declarations>
• Description:
• A public member can be accessed by any function.
• Members of a struct or union are public by default.
• You can override the default struct access with private or protected but you
cannot override the default union access.
• Friend declarations are not affected by these access specifiers.
Private Member Access Specifier
• Syntax
• private: <declarations>
• Description:
• A private member can be accessed only by member functions and friends of
the class in which it is declared.
• Class members are private by default.
• You can override the default struct access with private or protected but you
cannot override the default union access.
• Friend declarations are not affected by these access specifiers.
Protect Member Access Specifier
• Syntax
• protected: <declarations>
• Description:
• A protected member can be accessed by member functions and friends of the
class in which it was declared, and by classes derived (derived classes) from
the declared class.
• You can override the default struct access with private or protected but you
cannot override the default union access.
• Friend declarations are not affected by these access specifiers.
Example: Access Specifiers
class MyClass
{
public: //access from anywhere
int x;
private: //only access from within a class
int y;
protected: //access from within a class ,or derived class
int z;
};
void main()
{
MyClass CopyClass;
CopyClass.x = 1; //OK, Public Access.
CopyClass.y = 2; //Error! Y isn't a member of MyClass
CopyClass.z = 3; //Error! Z isn't a member of MyClass
}
Advantage of Encapsulation
• It prevents others accessing the insides of an object.
• The only thing that can manipulate the data in an object is that object’s
method or member function.
• It main aim is to prevent accident.
• It builds a protective wall (encapsulation) around the member data and
member function of the class, and hiding implementation details of object. So
It keeps data safe from accident.
Example: Encapsulation Or Information Hiding
(1/3)
#include <iostream>
// Declaration of the Box class.
class Box
{
private:
int height, width, depth; // private data members.
public:
Box(int, int, int);// constructor function.
~Box(); // destructor function.
int volume(); // member function (compute volume).
};
Example: Encapsulation Or Information Hiding
(2/3)
// Definition of the Box class.
Box::Box(int ht, int wd, int dp)// The constructor function.
{
height = ht;
width = wd;
depth = dp;
}
Box::~Box() //The destructor function. Use of scope resolution ‘::’
{
// does nothing
}
int Box::volume() // Member function to compute the Box's volume.
{
return height * width * depth;
}
Example: Encapsulation Or Information Hiding
(3/3)
// The main() function.
int main()
{
// Construct a Box object.
Box thisbox(7, 8, 9); // actual values
// Compute and display the object's volume.
int volume = thisbox.volume();
cout << “output volume is : “ << volume;
return 0;
}
RESULT:
output volume is: 504

More Related Content

What's hot (20)

PPTX
concept of oops
prince sharma
 
PPTX
Object oriented programming
Amit Soni (CTFL)
 
PPT
friend function(c++)
Ritika Sharma
 
PDF
Oops concepts || Object Oriented Programming Concepts in Java
Madishetty Prathibha
 
PPTX
Abstraction in java.pptx
AsifMulani17
 
PDF
Introduction to c++ ppt 1
Prof. Dr. K. Adisesha
 
PPTX
Object Oriented Programming Concepts for beginners
Vibhawa Nirmal
 
PPTX
Encapsulation
Githushan Gengaparam
 
PPT
PHP - Introduction to Object Oriented Programming with PHP
Vibrant Technologies & Computers
 
PPT
Files in c++ ppt
Kumar
 
PPTX
Classes, objects in JAVA
Abhilash Nair
 
PPTX
Access specifier
zindadili
 
PPTX
introduction of Object oriented programming
RiturajJain8
 
PPTX
Oop c++class(final).ppt
Alok Kumar
 
PPTX
07. Virtual Functions
Haresh Jaiswal
 
PPT
Function overloading(c++)
Ritika Sharma
 
PPTX
Introduction to oop
colleges
 
ODP
OOP java
xball977
 
PPTX
array of object pointer in c++
Arpita Patel
 
PPT
Class and object in C++
rprajat007
 
concept of oops
prince sharma
 
Object oriented programming
Amit Soni (CTFL)
 
friend function(c++)
Ritika Sharma
 
Oops concepts || Object Oriented Programming Concepts in Java
Madishetty Prathibha
 
Abstraction in java.pptx
AsifMulani17
 
Introduction to c++ ppt 1
Prof. Dr. K. Adisesha
 
Object Oriented Programming Concepts for beginners
Vibhawa Nirmal
 
Encapsulation
Githushan Gengaparam
 
PHP - Introduction to Object Oriented Programming with PHP
Vibrant Technologies & Computers
 
Files in c++ ppt
Kumar
 
Classes, objects in JAVA
Abhilash Nair
 
Access specifier
zindadili
 
introduction of Object oriented programming
RiturajJain8
 
Oop c++class(final).ppt
Alok Kumar
 
07. Virtual Functions
Haresh Jaiswal
 
Function overloading(c++)
Ritika Sharma
 
Introduction to oop
colleges
 
OOP java
xball977
 
array of object pointer in c++
Arpita Patel
 
Class and object in C++
rprajat007
 

Viewers also liked (17)

PPTX
Capsule technology [autosaved]
Abd Rhman Gamil gamil
 
PPT
Soft gelatin capsule
Arafat Jakir
 
PPTX
Encapsulation_ Problem and Remedies
Bhushan Ghike
 
PPT
An overview of encapsulation technologies for food
nooshin noshirvani
 
PPT
Capsules -Pharmaceutics
Areej Abu Hanieh
 
PPTX
Flavor encapsulation assignment
Arun Kumar Gupta
 
PPT
Capsule
maneavinash25
 
PPTX
Capsule Products Machines Manufacturer
SonuS International
 
PDF
Cgn280 semi automatic capsule filling machine
Sky Yang
 
PPTX
Validation of solid dosage forms in pharmaceutical industries
rasika walunj
 
PPTX
Process validation of capsules
pritam kumbhar
 
PPTX
Small scale and large scale capsule filling machine
ceutics1315
 
PPT
Microencapsulation.....in pharmacy by sandeep
Mollidain Sandeep
 
PPT
Controlled Release Oral Drug Delivery System
Ravishankar University, Raipur
 
PPT
Pharmaceutical Capsules
jojohen
 
PPTX
Capsules
gangoti yadav
 
PPT
Capsule's
Sunil Boreddy Rx
 
Capsule technology [autosaved]
Abd Rhman Gamil gamil
 
Soft gelatin capsule
Arafat Jakir
 
Encapsulation_ Problem and Remedies
Bhushan Ghike
 
An overview of encapsulation technologies for food
nooshin noshirvani
 
Capsules -Pharmaceutics
Areej Abu Hanieh
 
Flavor encapsulation assignment
Arun Kumar Gupta
 
Capsule
maneavinash25
 
Capsule Products Machines Manufacturer
SonuS International
 
Cgn280 semi automatic capsule filling machine
Sky Yang
 
Validation of solid dosage forms in pharmaceutical industries
rasika walunj
 
Process validation of capsules
pritam kumbhar
 
Small scale and large scale capsule filling machine
ceutics1315
 
Microencapsulation.....in pharmacy by sandeep
Mollidain Sandeep
 
Controlled Release Oral Drug Delivery System
Ravishankar University, Raipur
 
Pharmaceutical Capsules
jojohen
 
Capsules
gangoti yadav
 
Capsule's
Sunil Boreddy Rx
 
Ad

Similar to [OOP - Lec 08] Encapsulation (Information Hiding) (20)

PPTX
Module 4 Effect of Reuse on using Encapsulation.pptx
ramlingams
 
PPT
C# Encapsulation
Prem Kumar Badri
 
PPTX
Encapsulation C++ Piller of OOP it is the important piller
an7539661
 
PPTX
Prese00yq3whesfthewgdsyuvferwyjhjdfegcyjgfz.pptx
RajshreePathir
 
PPTX
Presentation related to Encapsulation and OOPs
vinitsinghthakur46
 
PPTX
Presentation - Copy no vaperpoit asd.pptx
RajshreePathir
 
PPTX
oop ppt.pptxfwefwefweqwedrqwerwerweewrewe
moeezrana329
 
PPTX
Presen5416846534653416354165341864adeadvdes
RajshreePathir
 
PPTX
Prese00z213hfcyudegtyfwyyudeqw7tgfi7u.pptx
RajshreePathir
 
PPT
C++Presentation 2.PPT
VENARATEKANHURU
 
PPTX
Encapsulation and inheritance
Chaudhary Kashif
 
PDF
encapsulation1-150816163959-lva1-app6891.pdf
kashafishfaq21
 
PPTX
Encapsulation_in_CPP_Presentation.pptxesfwefrwefrwefwefeqweqweqweqweqweqwe
moeezrana329
 
PPTX
2CPP09 - Encapsulation
Michael Heron
 
PPTX
ENCAPSULATION module for IT or comsci.pptx
MattFlordeliza1
 
PPTX
SAD05 - Encapsulation
Michael Heron
 
PPTX
CPP14 - Encapsulation
Michael Heron
 
PPTX
27csharp
Sireesh K
 
PPTX
27c
Sireesh K
 
PPTX
Presentation - 001jasfcjedhfuj5454545.pptx
RajshreePathir
 
Module 4 Effect of Reuse on using Encapsulation.pptx
ramlingams
 
C# Encapsulation
Prem Kumar Badri
 
Encapsulation C++ Piller of OOP it is the important piller
an7539661
 
Prese00yq3whesfthewgdsyuvferwyjhjdfegcyjgfz.pptx
RajshreePathir
 
Presentation related to Encapsulation and OOPs
vinitsinghthakur46
 
Presentation - Copy no vaperpoit asd.pptx
RajshreePathir
 
oop ppt.pptxfwefwefweqwedrqwerwerweewrewe
moeezrana329
 
Presen5416846534653416354165341864adeadvdes
RajshreePathir
 
Prese00z213hfcyudegtyfwyyudeqw7tgfi7u.pptx
RajshreePathir
 
C++Presentation 2.PPT
VENARATEKANHURU
 
Encapsulation and inheritance
Chaudhary Kashif
 
encapsulation1-150816163959-lva1-app6891.pdf
kashafishfaq21
 
Encapsulation_in_CPP_Presentation.pptxesfwefrwefrwefwefeqweqweqweqweqweqwe
moeezrana329
 
2CPP09 - Encapsulation
Michael Heron
 
ENCAPSULATION module for IT or comsci.pptx
MattFlordeliza1
 
SAD05 - Encapsulation
Michael Heron
 
CPP14 - Encapsulation
Michael Heron
 
27csharp
Sireesh K
 
Presentation - 001jasfcjedhfuj5454545.pptx
RajshreePathir
 
Ad

More from Muhammad Hammad Waseem (20)

PDF
[ITP - Lecture 17] Strings in C/C++
Muhammad Hammad Waseem
 
PDF
[ITP - Lecture 16] Structures in C/C++
Muhammad Hammad Waseem
 
PDF
[ITP - Lecture 15] Arrays & its Types
Muhammad Hammad Waseem
 
PDF
[ITP - Lecture 14] Recursion
Muhammad Hammad Waseem
 
PDF
[ITP - Lecture 13] Introduction to Pointers
Muhammad Hammad Waseem
 
PDF
[ITP - Lecture 12] Functions in C/C++
Muhammad Hammad Waseem
 
PDF
[ITP - Lecture 11] Loops in C/C++
Muhammad Hammad Waseem
 
PDF
[ITP - Lecture 10] Switch Statement, Break and Continue Statement in C/C++
Muhammad Hammad Waseem
 
PDF
[ITP - Lecture 09] Conditional Operator in C/C++
Muhammad Hammad Waseem
 
PDF
[ITP - Lecture 08] Decision Control Structures (If Statement)
Muhammad Hammad Waseem
 
PDF
[ITP - Lecture 07] Comments in C/C++
Muhammad Hammad Waseem
 
PDF
[ITP - Lecture 06] Operators, Arithmetic Expression and Order of Precedence
Muhammad Hammad Waseem
 
PDF
[ITP - Lecture 05] Datatypes
Muhammad Hammad Waseem
 
PDF
[ITP - Lecture 04] Variables and Constants in C/C++
Muhammad Hammad Waseem
 
PDF
[ITP - Lecture 03] Introduction to C/C++
Muhammad Hammad Waseem
 
PDF
[ITP - Lecture 02] Steps to Create Program & Approaches of Programming
Muhammad Hammad Waseem
 
PDF
[ITP - Lecture 01] Introduction to Programming & Different Programming Languages
Muhammad Hammad Waseem
 
PPTX
[OOP - Lec 20,21] Inheritance
Muhammad Hammad Waseem
 
PPTX
[OOP - Lec 19] Static Member Functions
Muhammad Hammad Waseem
 
PPTX
[OOP - Lec 18] Static Data Member
Muhammad Hammad Waseem
 
[ITP - Lecture 17] Strings in C/C++
Muhammad Hammad Waseem
 
[ITP - Lecture 16] Structures in C/C++
Muhammad Hammad Waseem
 
[ITP - Lecture 15] Arrays & its Types
Muhammad Hammad Waseem
 
[ITP - Lecture 14] Recursion
Muhammad Hammad Waseem
 
[ITP - Lecture 13] Introduction to Pointers
Muhammad Hammad Waseem
 
[ITP - Lecture 12] Functions in C/C++
Muhammad Hammad Waseem
 
[ITP - Lecture 11] Loops in C/C++
Muhammad Hammad Waseem
 
[ITP - Lecture 10] Switch Statement, Break and Continue Statement in C/C++
Muhammad Hammad Waseem
 
[ITP - Lecture 09] Conditional Operator in C/C++
Muhammad Hammad Waseem
 
[ITP - Lecture 08] Decision Control Structures (If Statement)
Muhammad Hammad Waseem
 
[ITP - Lecture 07] Comments in C/C++
Muhammad Hammad Waseem
 
[ITP - Lecture 06] Operators, Arithmetic Expression and Order of Precedence
Muhammad Hammad Waseem
 
[ITP - Lecture 05] Datatypes
Muhammad Hammad Waseem
 
[ITP - Lecture 04] Variables and Constants in C/C++
Muhammad Hammad Waseem
 
[ITP - Lecture 03] Introduction to C/C++
Muhammad Hammad Waseem
 
[ITP - Lecture 02] Steps to Create Program & Approaches of Programming
Muhammad Hammad Waseem
 
[ITP - Lecture 01] Introduction to Programming & Different Programming Languages
Muhammad Hammad Waseem
 
[OOP - Lec 20,21] Inheritance
Muhammad Hammad Waseem
 
[OOP - Lec 19] Static Member Functions
Muhammad Hammad Waseem
 
[OOP - Lec 18] Static Data Member
Muhammad Hammad Waseem
 

Recently uploaded (20)

PDF
0725.WHITEPAPER-UNIQUEWAYSOFPROTOTYPINGANDUXNOW.pdf
Thomas GIRARD, MA, CDP
 
PPTX
A PPT on Alfred Lord Tennyson's Ulysses.
Beena E S
 
PDF
The History of Phone Numbers in Stoke Newington by Billy Thomas
History of Stoke Newington
 
PPTX
CATEGORIES OF NURSING PERSONNEL: HOSPITAL & COLLEGE
PRADEEP ABOTHU
 
PDF
LAW OF CONTRACT (5 YEAR LLB & UNITARY LLB )- MODULE - 1.& 2 - LEARN THROUGH P...
APARNA T SHAIL KUMAR
 
PPT
Talk on Critical Theory, Part II, Philosophy of Social Sciences
Soraj Hongladarom
 
PDF
QNL June Edition hosted by Pragya the official Quiz Club of the University of...
Pragya - UEM Kolkata Quiz Club
 
PDF
CONCURSO DE POESIA “POETUFAS – PASSOS SUAVES PELO VERSO.pdf
Colégio Santa Teresinha
 
PPTX
grade 5 lesson matatag ENGLISH 5_Q1_PPT_WEEK4.pptx
SireQuinn
 
PDF
ARAL-Orientation_Morning-Session_Day-11.pdf
JoelVilloso1
 
PPTX
PATIENT ASSIGNMENTS AND NURSING CARE RESPONSIBILITIES.pptx
PRADEEP ABOTHU
 
PDF
DIGESTION OF CARBOHYDRATES,PROTEINS,LIPIDS
raviralanaresh2
 
PPTX
Universal immunization Programme (UIP).pptx
Vishal Chanalia
 
PDF
LAW OF CONTRACT ( 5 YEAR LLB & UNITARY LLB)- MODULE-3 - LEARN THROUGH PICTURE
APARNA T SHAIL KUMAR
 
PPTX
Cultivation practice of Litchi in Nepal.pptx
UmeshTimilsina1
 
PPTX
MENINGITIS: NURSING MANAGEMENT, BACTERIAL MENINGITIS, VIRAL MENINGITIS.pptx
PRADEEP ABOTHU
 
PDF
Isharyanti-2025-Cross Language Communication in Indonesian Language
Neny Isharyanti
 
PDF
Dimensions of Societal Planning in Commonism
StefanMz
 
PPTX
I AM MALALA The Girl Who Stood Up for Education and was Shot by the Taliban...
Beena E S
 
PDF
Exploring the Different Types of Experimental Research
Thelma Villaflores
 
0725.WHITEPAPER-UNIQUEWAYSOFPROTOTYPINGANDUXNOW.pdf
Thomas GIRARD, MA, CDP
 
A PPT on Alfred Lord Tennyson's Ulysses.
Beena E S
 
The History of Phone Numbers in Stoke Newington by Billy Thomas
History of Stoke Newington
 
CATEGORIES OF NURSING PERSONNEL: HOSPITAL & COLLEGE
PRADEEP ABOTHU
 
LAW OF CONTRACT (5 YEAR LLB & UNITARY LLB )- MODULE - 1.& 2 - LEARN THROUGH P...
APARNA T SHAIL KUMAR
 
Talk on Critical Theory, Part II, Philosophy of Social Sciences
Soraj Hongladarom
 
QNL June Edition hosted by Pragya the official Quiz Club of the University of...
Pragya - UEM Kolkata Quiz Club
 
CONCURSO DE POESIA “POETUFAS – PASSOS SUAVES PELO VERSO.pdf
Colégio Santa Teresinha
 
grade 5 lesson matatag ENGLISH 5_Q1_PPT_WEEK4.pptx
SireQuinn
 
ARAL-Orientation_Morning-Session_Day-11.pdf
JoelVilloso1
 
PATIENT ASSIGNMENTS AND NURSING CARE RESPONSIBILITIES.pptx
PRADEEP ABOTHU
 
DIGESTION OF CARBOHYDRATES,PROTEINS,LIPIDS
raviralanaresh2
 
Universal immunization Programme (UIP).pptx
Vishal Chanalia
 
LAW OF CONTRACT ( 5 YEAR LLB & UNITARY LLB)- MODULE-3 - LEARN THROUGH PICTURE
APARNA T SHAIL KUMAR
 
Cultivation practice of Litchi in Nepal.pptx
UmeshTimilsina1
 
MENINGITIS: NURSING MANAGEMENT, BACTERIAL MENINGITIS, VIRAL MENINGITIS.pptx
PRADEEP ABOTHU
 
Isharyanti-2025-Cross Language Communication in Indonesian Language
Neny Isharyanti
 
Dimensions of Societal Planning in Commonism
StefanMz
 
I AM MALALA The Girl Who Stood Up for Education and was Shot by the Taliban...
Beena E S
 
Exploring the Different Types of Experimental Research
Thelma Villaflores
 

[OOP - Lec 08] Encapsulation (Information Hiding)

  • 2. Encapsulation • “ to enclose in or as in a capsule ” • The object-oriented meaning of encapsulation is • to enclose related data, routines and definitions in a class capsule. This does not necessarily mean hiding. (Mish) • Encapsulation is the ‘bundling together’ of data and behavior so that they are inseparable. (Mcgraw Hill)
  • 3. Why Encapsulation called Information Hiding • Encapsulation (also called information hiding) consists of separating the external aspects of an object, from the internal implementation details of the object, which are hidden from other objects. • Encapsulation prevents a program from becoming to interdependent that a small change has massive ripple effects. • Encapsulation has ability to combine data structure and behavior in a single entity makes encapsulation cleaner and more powerful than in conventional languages that separate data structure and behavior.
  • 4. Information Hiding • Information Hiding: a module is characterized by the information it hides from other modules, which are called its clients. The hidden information remains a secret to the client modules. (Ghezzi et al) • Information hiding is the principle that users of a software component (such as a class) need to know only the essential details of how to initialize and access the component, and do not need to know the details of the implementation. (Budd)
  • 5. What Encapsulation Provides in OO? • The interface is the visible surface of the capsule. • The interface describes the essential characteristics of objects of the class which are visible to the exterior world. • Interface data – which should be visible from outside/other class or method. • The implementation is hidden in the capsule. • The implementation hiding means that data can only be manipulated, that is updated, within the class, but it does not mean hiding interface data. • Implementation data – which should be hidden from outside/other class or method.
  • 6. General 3 Ways to Encapsulate Data Public Member Access Specifier Private Member Access Specifier Protected Member Access Specifier
  • 7. Public Member Access Specifier • Syntax • public: <declarations> • Description: • A public member can be accessed by any function. • Members of a struct or union are public by default. • You can override the default struct access with private or protected but you cannot override the default union access. • Friend declarations are not affected by these access specifiers.
  • 8. Private Member Access Specifier • Syntax • private: <declarations> • Description: • A private member can be accessed only by member functions and friends of the class in which it is declared. • Class members are private by default. • You can override the default struct access with private or protected but you cannot override the default union access. • Friend declarations are not affected by these access specifiers.
  • 9. Protect Member Access Specifier • Syntax • protected: <declarations> • Description: • A protected member can be accessed by member functions and friends of the class in which it was declared, and by classes derived (derived classes) from the declared class. • You can override the default struct access with private or protected but you cannot override the default union access. • Friend declarations are not affected by these access specifiers.
  • 10. Example: Access Specifiers class MyClass { public: //access from anywhere int x; private: //only access from within a class int y; protected: //access from within a class ,or derived class int z; }; void main() { MyClass CopyClass; CopyClass.x = 1; //OK, Public Access. CopyClass.y = 2; //Error! Y isn't a member of MyClass CopyClass.z = 3; //Error! Z isn't a member of MyClass }
  • 11. Advantage of Encapsulation • It prevents others accessing the insides of an object. • The only thing that can manipulate the data in an object is that object’s method or member function. • It main aim is to prevent accident. • It builds a protective wall (encapsulation) around the member data and member function of the class, and hiding implementation details of object. So It keeps data safe from accident.
  • 12. Example: Encapsulation Or Information Hiding (1/3) #include <iostream> // Declaration of the Box class. class Box { private: int height, width, depth; // private data members. public: Box(int, int, int);// constructor function. ~Box(); // destructor function. int volume(); // member function (compute volume). };
  • 13. Example: Encapsulation Or Information Hiding (2/3) // Definition of the Box class. Box::Box(int ht, int wd, int dp)// The constructor function. { height = ht; width = wd; depth = dp; } Box::~Box() //The destructor function. Use of scope resolution ‘::’ { // does nothing } int Box::volume() // Member function to compute the Box's volume. { return height * width * depth; }
  • 14. Example: Encapsulation Or Information Hiding (3/3) // The main() function. int main() { // Construct a Box object. Box thisbox(7, 8, 9); // actual values // Compute and display the object's volume. int volume = thisbox.volume(); cout << “output volume is : “ << volume; return 0; } RESULT: output volume is: 504