adsense


Thursday, 26 November 2015

C++ LANGUAGE FUNDAMENTAL ELEMENTS

COMPUTER LANGUAGES HTML,C,C++.JAVA,.NET AND MULTIMEDIA basics and programs click home button



C++ LANGUAGE FUNDAMENTAL ELEMENTS




FUNDAMENTAL ELEMENTS 

All C++ programs are composed of the following two 
fundamental elements: 

• Program statements (code): This is the part of a 
program that performs actions and they are called functions. 

• Program data: The data is the information of the program 
which gets affected by the program functions. 

Encapsulation is an Object Oriented Programming concept 
that binds together the data and functions that manipulate 
the data, and that keeps both safe from outside interference 
and misuse. Data encapsulation led to the important OOP 
concept of data hiding. 

Data encapsulation is a mechanism of bundling the data, 
and the functions that use them and data abstraction is 
a mechanism of exposing only the interfaces and hiding the 
implementation details from the user. 

C++ supports the properties of encapsulation and data hiding 
through the creation of user-defined types, called classes. 
We already have studied that a class can contain private, 
protected and public members. By default, all items defined 
in a class are private. For example: 

class Box 
{ 
   public: 
      double getVolume(void) 
      { 
         return length * breadth * height; 
      } 
   private: 
      double length;      // Length of a box 
      double breadth;     // Breadth of a box 
      double height;      // Height of a box 
}; 

The variables length, breadth, and height are private. 
This means that they can be accessed only by other members 
of the Box class, and not by any other part of your program. 
This is one way encapsulation is achieved. 



No comments: