virtual Multinumber operator+(Multinumber); virtual Multinumber& operator=(Multinumber); virtual bool operator==(Multinumber); virtual string object2string(); virtual void makeobject(double, double)=0;
Then I have three subclasses (Pairs, Complex, and Rational), and in each of these subclasses I have to override each of these functions. This is turning out to be quite problematic though because the parameters for the virtual functions in Multinumber are of type Multinumber, and Multinumber is, obviously, an abstract class. I was hoping that since the other three classes are inherited from Multinumber the compiler wouldn't mind if I, for example, defined a function in Complex as
Complex operator+(Complex);
But the compiler is not recognizing this as the same function definition.
The class, Multinumber, looks like this:
#include "Multinumber.h"
using namespace std;
Multinumber::operator+(Multinumber num)
{
}
Multinumber::operator=(Multinumber num)
{
}
Multinumber::operator==(Multinumber num)
{
}
Multinumber::object2string()
{
}
Multinumber::makeobject(double x, double y)
{
}
In essence, I am trying to make all of the above functions dynamically binded but using different parameters so that I can use them polymorphically in a set data structure (for example, I cannot add a "Complex" to a "Rational.") Am I doing this incorrectly? I think I understand the theory behind it, but I am a little confused. Thank you for any help you can give me. If needed, I have included the relevant code as an attachment.
Attached File(s)
-
code.zip (4.26K)
Number of downloads: 48
This post has been edited by lunixer: 24 November 2010 - 02:16 PM

New Topic/Question
Reply



MultiQuote




|