M
Martin Magnusson
I want to create a few objects which all share a lot of common features,
so they should all derive from the same base class. However, each of
them needs individual definitions of two functions. So what I'd like to
do is to create a new object which is based on a class with virtual
functions, and define the virtual function when the object is created,
without having to define a new class for each object. Is there a good
way to do this in C++? (I know it's possible in Java.)
I suppose another way to go is to use funtion pointers, but I's like to
stay OO as much as I can.
Thanks,
Martin
so they should all derive from the same base class. However, each of
them needs individual definitions of two functions. So what I'd like to
do is to create a new object which is based on a class with virtual
functions, and define the virtual function when the object is created,
without having to define a new class for each object. Is there a good
way to do this in C++? (I know it's possible in Java.)
I suppose another way to go is to use funtion pointers, but I's like to
stay OO as much as I can.
Thanks,
Martin