May 2012
Intermediate to advanced
679 pages
16h 56m
English
The basic thing in any class is the constructor. We have studied constructor overloading. Hence, let us develop a class string with two constructors.
Figure 8.2 Pictorial view of our own class STRING
Problem: Develop two suitable constructors for class STRING.
Solution: In this class, we should be able to accept strings from the program. In C++, strings are handled with pointer to char. Hence we must have one constructor with standard string as input. There can be many other ways to construct STRING. Let us choose our second constructor as one which creates a null string. See Program 8.9.
Read now
Unlock full access