Can constructors be parameterized?

Yes we can have parameterized constructor which can also be termed as constructor overloading. Below is a code snippet which shows two constructors for pcdsMaths class one with parameter and one with out.
class pcdsMaths
double PI;
// This is the constructor for the maths constant class.
{PI = 3.14;}
pcdsMaths(int pi)
PI = pi;
} }

asked Sep 13, 2013 in oops by rajesh
edited Sep 12, 2013
0 votes

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.
Anti-spam verification:
To avoid this verification in future, please log in or register.