Basic fundamentals Flashcards
1
Q
Explicit and implicit constructor
A
Here we must pass the initial values as arguments to the constructor function when as object is declared. This is done in two ways:
By calling the constructor explicitly.
By calling the constructor implicitly.
The following declaration illustrates the first method:
integer int1 = integer(0,100); //explicit call
You can declare the constructor to be explicit.
This statement creates an integer object int1 and passes the values 0 & 100 to it. The second is implemented as follows: integer int1(0,100);// implicit call This method sometimes called as shorthand method, is very often as it is shorter, looks better and is easy to implement.