If I have something like this:
class NumberException {
};
class Number {
public:
...
virtual unsigned long getValue() {throw(NumberException);};
...
};
class Integer : public Number {
public:
...
virtual int getValue() {return Value;};
Integer(int i) {Value=i;};
...
private:
int Value;
};
class Float : public Number {
public:
....
virtual float getValue() {return Value};
Float(float f);
....
private:
float Value;
};
int main()
{
Float f(3.14);
Integer i(55);
cout<<f->getValue()<<" "<<i->getValue()<<endl;
}
GCC (and likelly any other ANSI compilor) barfs on getValue having different
return types while being virtual... is there any way around this problem...
the idea is I want to do a "everything is an object" style paradigm (ala
Ruby).
--Aryeh