C++ is an object oriented programming language created by BjarneStroustrup. It is released in 1985.
C++ doesn’t only maintains all aspects from C language, it also simplify memory management and add several features like:
Includes a new data type known as a class.
Allows object oriented programming.
|1)||C follows the procedural style programming.
C++ is multi-paradigm. It supports both procedural and object oriented.
|2)||Data is less secured in C.
In C++, you can use modifiers for class members to make it inaccessible for outside users.
|3)||C follows the top-down approach.
C++ follows the bottom-up approach.
|4)||C does not support function overloading.
C++ supports function overloading.
|5)||In C, you can’t use functions in structure.
In C++, you can use functions in structure.
|6)||C does not support reference variables.
C++ supports reference variables.
|6)||In C, scanf() and printf() are mainly used for input/output.
C++ mainly uses stream cin and cout to perform input and output operations.
Class is a user-defined data type. Class defines the type definition of category of things. It defines a data type, but it does not define the data it just specifies the structure of data.
You can create N number of objects from a class.
Object is the instance of a class. A class provides a blueprint for objects. So you can create an object from a class. The objects of a class are declared with the same sort of declaration that we declare variables of basic types.
There are three types of access specifiers:
Private: Functions and variables declared as private can be accessed only within the same class and they cannot be accessed outside the class they are declared.
Public: Functions and variables declared under public can be accessed from anywhere.
Encapsulation: Encapsulation is a mechanism which binds the data and associated operations together and thus hide the data from outside world. Encapsulation is also known as data hiding. In C++, It is achieved using the access specifies i.e. public, private and protected.
Abstraction: Abstraction is used to hide the internal implementations and show only the necessary details to the outer world. Data abstraction is implemented using interfaces and abstract classes in C++.
Some people confused about Encapsulation and abstraction. But they both are different.
Inheritance: Inheritance is used to inherit the property of one class into another class. It facilitates you to define one class in term of another class
Protected: Functions and variables declared as protected cannot be accessed outside the class except a child class. This specified is generally used in inheritance.
If you like this post then please share and like this post.
Visit us @ tccicomputercoaching.com
Call us @ 98256 18292.
Mail us email@example.com