May 2012
Intermediate to advanced
679 pages
16h 56m
English
It may be noted that a constructor is a function. C++ allows function overloading. Naturally, it allows constructor overloading. When a class has more than one constructor defined, it is said that constructors are overloaded. The constructors are then recognized depending on the parameters passed.
The Program 6.5 will define two objects. One will be initialized by a parameterized constructor; other will be initialized with a constructor without parameters.
Problem: Write a program to demonstrate constructor overloading.
Solution: See Program 6.5.
// const2.cpp#include<iostream.h>class Date{ private : int day, month, year; public: Date(); Date(int d, int m, int y); ...
Read now
Unlock full access