Computer Science - Object Oriented Programming Using C++ - Discussion
Discussion Forum : Object Oriented Programming Using C++ - Section 1 (Q.No. 13)
13.
If you design a class that needs special initialization tasks, you will want to design a(n) _____
Discussion:
4 comments Page 1 of 1.
Rohit Raj said:
1 year ago
If you design a class that needs special initialization tasks, you will want to design a constructor.
Constructors are special member functions in a class that is responsible for initializing the object's data members and performing any necessary setup tasks when an object of the class is created.
Constructors are special member functions in a class that is responsible for initializing the object's data members and performing any necessary setup tasks when an object of the class is created.
(1)
Zabiullah said:
8 years ago
What is housekeeping routing?
Majid iqbal said:
1 decade ago
"constructor" is a special public member function of the class, that is used to initialized an object (variable) of the same class.
It has the following characteristic.
1) "Contructor's" name must be same as class name.
2) It doesnt have any return type not even "void". Therefore it will return nothing.
3) It can have arguments (called parameterised constructor).
3) It must be public member of the class.
4) It get called automatically when object of same class is declared.
5) There are different types of constructors, such as
(a) default constructor
(b) parameterised constructor. (may be with default values)
(c) copy constructor.
It has the following characteristic.
1) "Contructor's" name must be same as class name.
2) It doesnt have any return type not even "void". Therefore it will return nothing.
3) It can have arguments (called parameterised constructor).
3) It must be public member of the class.
4) It get called automatically when object of same class is declared.
5) There are different types of constructors, such as
(a) default constructor
(b) parameterised constructor. (may be with default values)
(c) copy constructor.
(1)
PRABHU said:
1 decade ago
Please give the explanation.
Post your comments here:
Quick links
Quantitative Aptitude
Verbal (English)
Reasoning
Programming
Interview
Placement Papers