Namespaces
Variants
Actions

intro/encapsulation

From cppreference.com
Revision as of 06:32, 25 November 2013 by 91.215.149.122 (Talk)

Encapsulation is one of the most fundumental and valuable features of object oriented programming in general and c++ in particular. The ability to hide the details from the user of your code and encapsulate everything under a clear interface is a great advantage.
example:

class sqaure{
public:
  rectangle( int top_left, int top_right, int buttom_left, buttom_right )
private:
  std::pair<int, int> top;
  std::pair<int, int> buttom;
};

In this example the interface calls for 4 integers and the implementation uses 2 pairs. The implementation along with the activities (not shown here) on the variables is encapsulated within the class.