C++
C | C++ |
---|---|
C is a procedure-oriented programming language. | C++ is a object-oriented programming language. |
C does not support data hiding. | Data is hidden by encapsulation to ensure that data structures and operators are used as intended. |
C is a subset of C++ | C++ is a superset of C. |
Function and operator overloading are not supported in C | Function and operator overloading is supported in C++ |
Namespace features are not present in C | Namespace is used by C++, which avoids name collisions. |
Functions can not be defined inside structures. | Functions can be defined inside structures. |
|
|
Data types
Primitive Datatype(basic datatype). Examples-
char
,short
,int
,float
,long
,double
,bool
, etc.Derived datatype. Example- array, pointer, etc.
Enumeration. Example-
enum
User-defined data types. Example- structure, class, etc.
Access Specifiers
Public: All data members and member functions are accessible outside the class.
Protected: All data members and member functions are accessible inside the class and to the derived class.
Private: All data members and member functions are not accessible outside the class.
No destructor overloading is not possible. Destructors take no arguments, so there’s only one way to destroy an object. That’s the reason destructor overloading is not possible.
Call by Value | Call by Reference |
---|---|
In call by value method, we pass a copy of the parameter is passed to the functions. For these copied values a new memory is assigned and changes made to these values do not reflect the variable in the main function. | In call by reference method, we pass the address of the variable and the address is used to access the actual argument used in the function call. So changes made in the parameter alter the passing argument. |
Last updated