5.0 Unique features of C++
C++ programming languages is based on the C language. It is known as middle level language compare with both low level and high level languages features. In C++, user can develop new data types that contain member function, or also known as functional descriptions, as well as data representations. These new data types are called classes. Developing such classes is call data abstraction. User can combine the classes from class libraries, develop their own classes, or derive new classes from existing classes. The new classes can have inherit properties from one or more classes. The classes describe the data type and function available but these classes can be hide, or call as encapsulate the implementation details from the client programs. To override the implementation in a derived class, user need to declare a class member function in a base class. This ability to select the function at run time which depend on the data type, is called polymorphism. So, there are four unique features in C++: Abstraction, Inheritance, Encapsulation, and Polymorphism.
Encapsulation:
Encapsulation is a process of hiding the information to ensure the data structures and operators are used intended. The programmer cannot directly access the data but the data can be access through the function that present inside the class (The unique features of C in programming. (2013)). In C++, the keywords that normally use are protected, private and public which also refer as “access specifies”. The keyword public that placed before the elements is accessible to all the user of the class. The keyword protected that placed before the elements is accessible only to the methods of the class. The keyword private that place before the elements are accessible only to the methods of the class. By declaring the data which hidden inside the class is declared as private inside the class. This private data cannot be directly accessed by the object. (MR, T. (2010, April 14). Data Hiding and Encapsulation - C Programming Concepts.)
Abstraction:
Data abstraction is the most powerful and vital features in C++ programming language. It is very important as it provide flexibility to users for using the programming language. It give a clear separation between properties of datatype and the associated implementation details. To achieve this separation, the properties of abstraction are visible and the implementation details are hidden (The unique features of C in programming. (2013)). It forms the basic platform for creating the objects. Data abstraction is the process of the refining data to its essential form. A data type that defined in term of the operation that the data type supports is defined as abstract data type. It is not in term of its structure or any implementation. The are two type of abstraction: functional abstraction and data abstraction. The difference between this two abstraction is that functional abstraction is a function that can be used without taking into account how the data stored while data abstraction is the data can be used without taking into account how the data stored. The advantages of using abstraction is that it is flexible in approach, enhanced security, easier replacement, and modular approach. (R, S. (2007, April 26). C Abstraction)
Inheritance:
In C++, inheritance allow user to define a class in terms of another class. By using this method, it is easier to create and maintain an application, reuse the code functionality, and also fast implementation time. This is the process where user create a new classes called derived classes from existing classes which called base classes. The features in the base class will also can be found in derived classes (The unique features of C in programming. (2013)). Inheritance implement the is-a relationship. For example: boy IS-A person, Ali IS-A boy hence Ali IS-A person. In C++, there are 5 different types of inheritance, which are single inheritance, multiple inheritance, hierarchical inheritance, multilevel inheritance, and virtual inheritance. For single inheritance, one derived class inherits from only one base class. For multiple inheritance, one derived class may inherit from two or more base classes. For hierarchical inheritance, multiple derived classes inherits from one base class. For multilevel inheritance, the derived class inherits from a class, which in turn inherits from some other class. For virtual inheritance, it is a combination of hierarchical inheritance and multilevel inheritance.( Diwan, A. (2014). C Tutorial).
Polymorphism:
Polymorphism occurs when there is a hierarchy of classes and they are related by inheritance. It is the ability to use an operator or function in different ways. The word “Poly” mean that many uses of these operators and functions (The unique features of C in programming. (2013)). In C++, polymorphism mean that a call to a member function will cause a different function to be executed depending on the type of object that invokes the function. There are two different types of polymorphism: static (compile time) and dynamic (run time). Static polymorphism is exhibited by overloaded functions. Dynamic polymorphism is exhibited by using late binding. Static polymorphism refers as an entity existing in different physical forms simultaneously. It involves binding of functions based on the number, type and sequence of arguments. The various types of parameters are specified in the function declaration and the function can be bound to call at compile time, or called early binding. Dynamic polymorphism refers as an entity changing its form depending on the circumstances. Dynamic polymorphism occurs when a function has more than one form, and its various forms are resolved when the program is executed. The term late binding refers to the resolution of the functions at run time. This feature increase the flexibility of the program by allowing the appropriate method to be invoked, and this need to depend on the context. (Polymorphism. (2008). )
C++ programming languages is based on the C language. It is known as middle level language compare with both low level and high level languages features. In C++, user can develop new data types that contain member function, or also known as functional descriptions, as well as data representations. These new data types are called classes. Developing such classes is call data abstraction. User can combine the classes from class libraries, develop their own classes, or derive new classes from existing classes. The new classes can have inherit properties from one or more classes. The classes describe the data type and function available but these classes can be hide, or call as encapsulate the implementation details from the client programs. To override the implementation in a derived class, user need to declare a class member function in a base class. This ability to select the function at run time which depend on the data type, is called polymorphism. So, there are four unique features in C++: Abstraction, Inheritance, Encapsulation, and Polymorphism.
Encapsulation:
Encapsulation is a process of hiding the information to ensure the data structures and operators are used intended. The programmer cannot directly access the data but the data can be access through the function that present inside the class (The unique features of C in programming. (2013)). In C++, the keywords that normally use are protected, private and public which also refer as “access specifies”. The keyword public that placed before the elements is accessible to all the user of the class. The keyword protected that placed before the elements is accessible only to the methods of the class. The keyword private that place before the elements are accessible only to the methods of the class. By declaring the data which hidden inside the class is declared as private inside the class. This private data cannot be directly accessed by the object. (MR, T. (2010, April 14). Data Hiding and Encapsulation - C Programming Concepts.)
Abstraction:
Data abstraction is the most powerful and vital features in C++ programming language. It is very important as it provide flexibility to users for using the programming language. It give a clear separation between properties of datatype and the associated implementation details. To achieve this separation, the properties of abstraction are visible and the implementation details are hidden (The unique features of C in programming. (2013)). It forms the basic platform for creating the objects. Data abstraction is the process of the refining data to its essential form. A data type that defined in term of the operation that the data type supports is defined as abstract data type. It is not in term of its structure or any implementation. The are two type of abstraction: functional abstraction and data abstraction. The difference between this two abstraction is that functional abstraction is a function that can be used without taking into account how the data stored while data abstraction is the data can be used without taking into account how the data stored. The advantages of using abstraction is that it is flexible in approach, enhanced security, easier replacement, and modular approach. (R, S. (2007, April 26). C Abstraction)
Inheritance:
In C++, inheritance allow user to define a class in terms of another class. By using this method, it is easier to create and maintain an application, reuse the code functionality, and also fast implementation time. This is the process where user create a new classes called derived classes from existing classes which called base classes. The features in the base class will also can be found in derived classes (The unique features of C in programming. (2013)). Inheritance implement the is-a relationship. For example: boy IS-A person, Ali IS-A boy hence Ali IS-A person. In C++, there are 5 different types of inheritance, which are single inheritance, multiple inheritance, hierarchical inheritance, multilevel inheritance, and virtual inheritance. For single inheritance, one derived class inherits from only one base class. For multiple inheritance, one derived class may inherit from two or more base classes. For hierarchical inheritance, multiple derived classes inherits from one base class. For multilevel inheritance, the derived class inherits from a class, which in turn inherits from some other class. For virtual inheritance, it is a combination of hierarchical inheritance and multilevel inheritance.( Diwan, A. (2014). C Tutorial).
Polymorphism:
Polymorphism occurs when there is a hierarchy of classes and they are related by inheritance. It is the ability to use an operator or function in different ways. The word “Poly” mean that many uses of these operators and functions (The unique features of C in programming. (2013)). In C++, polymorphism mean that a call to a member function will cause a different function to be executed depending on the type of object that invokes the function. There are two different types of polymorphism: static (compile time) and dynamic (run time). Static polymorphism is exhibited by overloaded functions. Dynamic polymorphism is exhibited by using late binding. Static polymorphism refers as an entity existing in different physical forms simultaneously. It involves binding of functions based on the number, type and sequence of arguments. The various types of parameters are specified in the function declaration and the function can be bound to call at compile time, or called early binding. Dynamic polymorphism refers as an entity changing its form depending on the circumstances. Dynamic polymorphism occurs when a function has more than one form, and its various forms are resolved when the program is executed. The term late binding refers to the resolution of the functions at run time. This feature increase the flexibility of the program by allowing the appropriate method to be invoked, and this need to depend on the context. (Polymorphism. (2008). )