CS 202 Fall 2013 > In-Class Challenge for Thursday, October 17, 2013 |
CS 202 Fall 2013
In-Class Challenge for Thursday, October 17, 2013
Class Func
You are given an abstract base class Func
,
defined in files
func.h
and
func.cpp
.
This class has a virtual member function f
,
which in const
,
takes an int
and returns an int
.
It should be overridden in each derived class.
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, put all the code you write into a single file.
- Using as little code as possible, write:
- At least two derived classes of
Func
, each with a differentf
member. - A main program that creates a
vector
ofshared_ptr<Func>
, places pointers to at least three derived class objects in thevector
, then iterates through the vector, calling thef
member with some integer parameter.
- At least two derived classes of
Note: Your compiler should
have shared_ptr
.
If it does not,
then you can use plain pointers
(Func *
).
But I suggest you get a new compiler.
CS 202 Fall 2013: In-Class Challenge for Thursday, October 17, 2013 /
Updated: 17 Oct 2013 /
Glenn G. Chappell