May 2012
Intermediate to advanced
679 pages
16h 56m
English
We have studied interactive constructors. They help us in creating objects with input from keyboard. Let us use this concept with class STRING.
Program: Write a program to illustrate Interactive constructor for class STRING.
Solution: In general, to read any arbitrary string (including blanks) we have to use methods gets() or getline(). If we want a method independent of these routines, we will have to read characters directly from the console. For this purpose, we can use getche() function from header “conio.h”.
When we read characters from console, we must know when to stop. If we read 80 characters, we should stop. If we get any non-printable character, we should stop. Method isprint() from header ...
Read now
Unlock full access