I have base class Array in which I have virtual function Add for addition
class Array
{
public:
unsigned char arr[100] = { 0 };
int size;
Array();
Array(int);
char operator[](int);
virtual Array& Add( Array);
};
I have two derived classes Hex ( for storing hexidecimal numbers ) and BitString( for storing binary numbers ):
class BitString : public Array
{
public:
BitString& operator&(BitString&);//and
BitString& operator|(BitString&);//or
BitString& operator^(BitString&);//xor
BitString& operator~();//not
};
class Hex: public Array
{
public:
Hex& operator+(Hex);
Hex& operator-(Hex);
Hex& operator*(Hex);
Hex& operator/(Hex);
bool operator==(const Hex);
bool operator>(const Hex);
bool operator<(const Hex);
Hex DecToHex(int);
};
My task, except make operators for Hex and BitString, is to override virtual Add function for addition BitString and Hex objects.
I dont properly get :
1) Need I make 2 functions in both Hex and BitString
2) What these functions should return? Hex, BitString or Array.
3) What is the fastest way to do this? Convert both Hex and BitString to decimals, make addition and then convert again?
Thank you.