June-2018
* A Constructor is a member function with the same name as that of its class and it is used to initialize the object of that class type with a legal initial value.* Constructors are automatically invoked by the compiler.
* A Destructor is a member function with the same name as that if its class but is preceded by a tilde(~) and it is used deinitializes an object.
link: https://www.youtube.com/watch?v=X_yruQkVGUs
C++ can constructor be private
Can a constructor be private in C++ ?
https://www.geeksforgeeks.org/can-constructor-private-cpp/
Constructor Overloading. Constructor can beoverloaded in a similar way as function overloading.Overloaded constructors have the same name (name of the class) but different number of arguments. Depending upon the number and type of arguments passed, specific constructor is called.
C++ Programming Default Arguments (Parameters) - Programiz
https://www.programiz.com/cpp-programming/default-argument
In C++ programming, you can provide default values for function parameters. The idea behind default argument is simple. If a function is called by passing ...
*How does a class
enforce data-hiding, abstraction, and encapsulation?
A class
binds together data and its associated functions under one unit thereby
enforcing encapsulation as encapsulation means wrapping up data and associated
functions together into a single unit.
A class groups its members into three sections: private,
protected and public. The private and protected members remain hidden from
outside world. Thus through private and protected members, a class enforces
data-hiding.
The outside world is given only the essential and necessary
information through public members, rest of the things remains hidden, which is
nothing but abstraction. As abstraction means representation of essential
features without including the background details or explanation.
Enlist some
advantages of opp.
i.
Reusability of code
ii.
Ease of comprehension
iii.
Ease of fabrication and maintenance
iv. Easy redesign and extension
No comments:
Post a Comment