POO - Incapsulazione dei dati POO - encapsulação dos dados OOP - Datenkapselung POO - Encapsulation des données POO - Encapsulación de datos

The concept of encapsulation

Encapsulation is a way of organising data and methods into a structure by concealing the the way the object is implemented, i.e. preventing access to data by any means other than those specified. Encapsulation therefore guarantees the integrity of the data contained in the object.

Concealing data

The user of a particular class does not need to know how the data in that object is structured, this means that a user does not need to know how implementation takes place. By preventing the user from directly modifying attributes, and forcing the user to use defined functions in order to modify them (called interfaces), data integrity is thus ensured (for example, one can ensure that the data type given matches expectations, or is returned within the expected time interval).

Encapsulation defines the access levels for elements of that class. These access levels define the access rights to the data, allowing us to access the data by a method of that particular class itself, from an inheritance class, or even from any other class. There are three levels of access:

  • public: functions of all classes may access the data or methods of a class that is defined with the public access level. This is the lowest level of data protection
  • protected: data access is restricted to functions of inheritance classes, i.e. member functions of that class and all sub-classes
  • private: data access is restricted to methods of that particular class only. This is the highest level of data protection


Last update on Thursday October 16, 2008 02:43:13 PM.This document entitled « OOP - Data encapsulation » from Kioskea (en.kioskea.net) is made available under the Creative Commons license. You can copy, modify copies of this page, under the conditions stipulated by the licence, as this note appears clearly.
Best answers for « OOP Data encapsulation » in :
Data transmission - Cabling Show Cabling types Several physical data-transmission media are available to connect together the various devices on a network. One possibility is to use cables. There are many types of cables, but the most common are: Coaxial cable Double twisted...
Data transmission - Introduction Show Data representation The purpose of a network is to transmit information from one computer to another. To do this, you first have to decide how to encode the data to be sent, in other words its computer representation. This will differ according to...
Data transmission - The physical connection Show What is a transmission channel? A transmission line is a connection between two machines. The term transmitter generally refers to the machine that sends the data while receiver refers to the one receiving the data. The machines can sometimes be...
Backup Outlook 2003 data ShowBackup Outlook 2003 data All Outlook 2003 data ( Emails, Agenda, Contacts, Tasks...) are in one file with .pst extension The file is in the following default folder: C:\Documents and Settings\Login\Local Settings\Application...
Start a database with a missing data file ShowStart a database with a missing data file In order to start an Oracle database with a misssing data file: First get connected to SQL*DBA or Server Manager and run "shutdown abort" Run startup mount Run the following...
Secure data entry in C ++ ShowSecure data entry in C ++ Using get () Using "getline ()" Remove go to newline without using getline () Sometimes when creating a program, it is needed that additional information from the user must be enterd. In C++...
Download Aqua Data Studio ShowAqua Data Studio is an advanced SQL editor. It can create, edit and execute SQL scripts. This software provides an integrated database with only one interface for connecting to databases. Query Analyzer enables users to work on RDBMS synthax and auto...
Download Advanced TCP IP Data Logger ShowDescription: Advanced TCP/IP Data Logger will help you in your daily technical needs. You will be able to get information about your network and any device that is connected to it in real time. Features: You can send and receive serial data...
Data transmission - Analogue transmission ShowThe principles of analogue transmission Analogue data transmission consists of sending information over a physical transmission medium in the form of a wave. Data is transmitted via a carrier wave, a simple wave whose only purpose is to transport...
EDGE (Enhanced Data Rates for GSM Evolution) ShowIntroduction to the EDGE standard The EDGE (Enhanced Data Rates for GSM Evolution.) standard is an evolution of the GSM standard that modifies the type of modulation. Like the GPRS standard, the EDGE standard is intended to be a transition to third...
Data levels ShowANSI/SPARC levels The ANSI/SPARC architecture, which dates from 1975, defines abstraction levels for a database management system: Internal (or physical) level: defines how data is stored, and how it is accessed. Conceptual level: also called the...