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
string
member with get and set functionsgetString
andsetString
, 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
out
that prints the string to a given output stream, orcout
if 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
Back
derived fromStrPrint
. This new class should override functionout
to print the string backwards. - Your program should make objects of
type
StrPrint
andBack
and call member functionout
on each, using a pointer of type(StrPrint *)
. - Write another class derived from
StrPrint
that 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