| CS 202 Fall 2013 > In-Class Challenge for Tuesday, October 15, 2013 |
CS 202 Fall 2013
In-Class Challenge for Tuesday, October 15, 2013
Class StrPrint
A class StrPrint
is defined for you,
in files
strprint.h
and
strprint.cpp.
This class has:
- A
stringmember with get and set functionsgetStringandsetString, written as usual. - A constructor that sets the string member to a given value.
- A default constructor that sets the string member to the empty string.
- A virtual member function
outthat prints the string to a given output stream, orcoutif no stream is given.
What to Do
Do as many of the following as you can before class ends.
Along the way, maintain a program that demonstrates
whatever functionality you have written.
To allow for faster writing,
you may put all the code you write into a single file,
if you wish.
But avoid modifying strprint.h
or strprint.cpp.
- Write a class
Backderived fromStrPrint. This new class should override functionoutto print the string backwards. - Your program should make objects of
type
StrPrintandBackand call member functionouton each, using a pointer of type(StrPrint *). - Write another class derived from
StrPrintthat prints a string in some other (interesting?) way. Add code that uses it to your program.
Some Reminders
- Get things to compile first, right?
- Don’t Repeat Yourself!
CS 202 Fall 2013: In-Class Challenge for Tuesday, October 15, 2013 /
Updated: 15 Oct 2013 /
Glenn G. Chappell