C++ Dynamic Initialization of Objects
The Dynamic Initialization of Objects means to initialize the data members of the class while creating the object. When we want to provide initial or default values to the data members while creating of object - we need to use dynamic initialization of objects.
Now, the question is how to achieve or implement dynamic initialization of objects?
It can be implemented by using parameterized constructors in C++.
Example:
Here, we have a class named "Student" which contains two private data members 1) rNo - to store roll number and 2) perc - to store percentage.
Program:
Output