Monday, April 20, 2020

C++ OOP (object oriented programming)

C++ OOP (object-oriented programming):


c++ oop


C++ is also super-set  of C, which means every C program is also a legal C++ program.

C++ OOP is also  a statically typed, compiled, general-purpose, case-sensitive, a free form programming language that supports procedural, object-oriented, and generic programming.

C++ OOP was developed by Bjarne Stroustrup starting in 1979 at Bell Labs in Murray Hill, New Jersey, as an enhancement to the C language and originally named C with Classes but then it's name was changed to C++ in 1983.

Object:


C++ OOP introduces object-oriented programming (OOP) features to C. 
It offers classes, which provide the four features commonly present in OOP  (and some non-OOP) languages:


FOUR MAIN KEY POINTS OF C++ OOP


1-Abstraction,
2- Inheritance
3- Polymorphism
4-Encapsulation


Abstraction:


Abstraction is also among the key concepts of C++ OOP.

Abstraction means to hide something unwanted details and exposing only the essential features of an object or concept. Abstraction is supported using the interface and an abstract class. Abstraction only focuses on what the object does instead of how it does.


Inheritance:


A very important aspect in the object-oriented program is inheritance. In Inheritance, you can use a code more than one time in the same program. As the name of the topic suggests that you can make other classes from the already existing classes.

In C++ OOP Inheritance means that you can use a code more than one time the re-usability of code have been made possible in C++ OOP


Polymorphism:


In C++ OOP:

Polymorphism means “many shapes.” It refers to the ability of one object to have many types. If we have a function that expects a Vehicle object, we can safely pass it a Car object, because every Car is also a Vehicle. This is how polymorphism works.


Encapsulation:


Encapsulation in C++ OOP is defined as:

Grouping of related data and functions together as objects and defining an interface to those objects is called Encapsulation.
Here it is clarified which object is engaged on which function.


I hope that you have already understood the concept of C++ Template which we have discussed earlier in introduction to C++.


CLASSES:


A class in C++ is a user-defined type or data structure declared with the keyword class that has data and functions (also called member variables and member functions) as its members whose depends upon the following three access specifiers:

1.     Private
2.     protected 
3.     Public.

 Public Members :

Members declared public within a class can also be accessed outside class but and within a program. Public members can be accessed using direct access operator (.) with the object of the class.

Private Members :


Members declared private cannot be accessed or even viewed by any object or function outside the class. Only the member functions or friend functions can access private members.

Protected Members :


Members declared protected cannot be accessed outside the class but they can be accessed by any derived class of that class. 


By default access to members of a C++ class is private. Private members cannot be accessed outside the class. They can be accessed only through methods of the class. The public members form an interface to the class and are accessible outside the class.


Library in C++ OOP:


The library of C++ OOP is categorized into two types:

  1. The Standard Function Library
  2. The Object-Oriented Class Library

The Standard Function Library:


It is further categorized into following:

<iostream>   It  Contains function prototypes for the C++ standard input and standard output functions. 

<cmath>    it Contains function prototypes for math library functions.

<cstdlib>   It  Contains function for conversions of numbers to text.

<ctime>      It Contains function and types for manipulating the time and date.

<cstring>     It Contains function prototypes for C-style string-processing functions.

<cstdio>     It Contains function  for the C-style standard input/output library functions and information used by them.

<fstream>    It Contains functions that perform input from files on disk and output to files on disk.
 

<string>     It Contains the definition of class string from the C++ Standard Library. 

The Object-Oriented Class Library:


 The class library is further categorized into following:

  • The String Class
  • The Numeric Classes
  • The STL Algorithms
  • The STL Function Objects

THANK YOU FOR READING THE ARTICLE I HOPE THAT IT HELPED U.


No comments:

Post a Comment

If else in c

IF Else in C: If-else in c: If else is the most used condition in our life. Whenever we need to make any decision we use...