Constructer without any argument
(default constructor).
Let name of class is “list” and “size” and “fill” are two
data members(variables) and "arr" is array in a class then constructor without argument will be
list :: list()
{ size=10;
arr=new int [size];
fill=-1;
}
Here we give values to size=10, and fill=-1, this is a
default constructer,
Constructer
with one parameter.
Let name of
class is “list” and “size” and “fill” are two data members (variables) and "arr" is array in a
class then constructor with one argument will be
list :: list(int num)
arr=new int [size];
fill=-1;
}
No comments:
Post a Comment