S
SpoonfulofTactic
I am working on a new library for my own use that
would allow me to use SI Units and to convert
them back and forth with ease.
However, While I have been working on operator
overloading, I have come accross a problem:
If I want to be able to simplify units through
operators, I end up with inter-dependant classes.
1 class Area {
2 public:
3 Area operator+(const Area& addend);
4 Area& operator+=(const Area& addend);
5 Area operator*(const float scalar);
6 Area operator*(const int scalar);
7 Length operator/(const Length& addend);
8 };
9
10 class Length {
11 public:
12 Length operator+(const Length& addend);
13 Length& operator+=(const Length& addend);
14 Length operator*(const float scalar);
15 Length operator*(const int scalar);
16 Area operator*(const Length& multiplier);
17 };
This tells me that I cannot have no type on the "Length" token on line
7.
What am I to do?
would allow me to use SI Units and to convert
them back and forth with ease.
However, While I have been working on operator
overloading, I have come accross a problem:
If I want to be able to simplify units through
operators, I end up with inter-dependant classes.
1 class Area {
2 public:
3 Area operator+(const Area& addend);
4 Area& operator+=(const Area& addend);
5 Area operator*(const float scalar);
6 Area operator*(const int scalar);
7 Length operator/(const Length& addend);
8 };
9
10 class Length {
11 public:
12 Length operator+(const Length& addend);
13 Length& operator+=(const Length& addend);
14 Length operator*(const float scalar);
15 Length operator*(const int scalar);
16 Area operator*(const Length& multiplier);
17 };
This tells me that I cannot have no type on the "Length" token on line
7.
What am I to do?