Which is the correct syntax for using default arguments with the constructor?

Which is the correct syntax for using default arguments with the constructor?
A. default constructorName(default int x=0)
B. constructorName(default int x=0)
C. constructorName(int x=0)
D. constructorName()
 
Answer: c
Explanation: The constructors using the default arguments must initialize the arguments in the argument list. This is to make the constructor use the default value when no arguments are passed. If no arguments are listed then it is a default constructor.
 

Tìm kiếm

Back
Top