Topic: Redefinition of function args possible?
Author: hans.wegener@gmd.de (Hans Wegener (in Ergo/WoK))
Date: Sat, 12 Mar 1994 13:45:47 GMT Raw View
Hi out there,
I am currently fighting with my C++ compiler to teach it redefinition of
function arguments. However, it refuses to do as I like it to, and I was
wondering if anyone could help me out of this...
I have a class called `Model' and an associated class `Interface'. These two
work together in the following way (private and protected clauses left out
for brevity):
class Interface
{
Interface(); // initializes interface stuff
~Interface(); // releases memory etc.
virtual interact();
};
class Model
{
Model();
~Model();
virtual loop(Interface *);
};
The idea about this is to get an abstract view of applications; every
application enters a main processing `loop', out of which it returns if
finished. Every user interface is initialized and then we can handle the
interaction with the user in the central processing loop `interact'.
Now, if I want to model an application with the property of having one flag
that is in some unknown way toggled by the user (say, a button in a window),
I may define:
class FlagModel: public Model
{
virtual loop(Interface *);
};
class ButtonInterface: public Interface
{
int flagIsOn;
ButtonInterface();
~ButtonInterface();
virtual interact();
};
This, however, is no clean solution to my problem, as the `FlagModel' assumes
to be coupled with an `Interface' with an additional property, i.e.
`flagIsOn'. And that can not be asserted, as the argument to `loop' is an
`Interface', but not a `ButtonInterface'. This is what I need argument
refinement for. In my mind, I could simply state:
class FlagModel: public Model
{
virtual loop(ButtonInterface *);
};
But here the trouble starts: my compiler (gcc to be exact) expects
`virtual loop(Interface *)' to be defined and implemented in `FlagModel', but
I don't want to allow for this. If I leave out definition and implementation
of this function, I get an `unknown symbol' error at link time.
Thus, to come to an end, my question is: Is this a feature of standard C++, of
gcc in particular or not? And if it is, is there a workaround?
Any pointers or direct e-mail greatly appreciated.
HW
------------------------------------------------------------------------------
Hans Wegener Phone: +49 2241 14 2840
GMD SET/SKS Fax: +49 2241 14 2889
Schloss Birlinghoven
D - 53754 St. Augustin
Germany E-Mail: hans.wegener@gmd.de
------------------------------------------------------------------------------