Parameterized Constructors
A default constructor initilizes the data mambers of all objects with the same set of values. However, in practice, it may be necessary to initialize the various data elements of different objects with different values when they are created. Often you will allow users of your classes to pass arguments to the constructor. This can be achieved by passing arguments to constructor functions when the objects are created. Constructors that can take arguments are called Parameterized Constructors
For example, the default constructor number() may be modified as given below:

No comments: