This code is giving me two errors that I just can't work out.
#include <iostream>
using namespace std;
class cBox
{
public:
cBox(double iLength = 2.0, double iWidth = 2.0, double iHeight = 2.0):
Length(iLength),
Width(iWidth),
Height(iHeight)
{ };
cBox(const cBox& aBox);
~cBox();
bool operator>(const cBox& aBox) const
{
return (this->Volume()) > (aBox.Volume());
}
bool operator>(const double& Value) const
{
return (this->Volume()) > Value;
}
inline double Volume() const
{
return Height * Width * Length;
}
private:
double Height;
double Width;
double Length;
};
cBox::cBox(const cBox& aBox)
{
Height = aBox.Height;
Length = aBox.Length;
Width = aBox.Width;
}
cBox::~cBox() { }
bool operator>(const double& Value, const cBox aBox);
int main(void)
{
cBox SmallBox(2.0, 2.0, 2.0);
cBox MediumBox(4.0, 4.0, 4.0);
cBox LargeBox(10.0, 10.0, 10.0);
if (MediumBox > SmallBox)
cout << "Medium is larger than Small" << endl;
else
cout << "Small is larger than Medium" << endl;
if (SmallBox > 50.0)
cout << "Small box is larger than 50" << endl;
else
cout << "Small box is less than 50" << endl;
if(50.0 > MediumBox)
cout << "50 is greater than medium box" << endl;
else
cout << "50 is less than medium box" << endl;
return 0;
}
The erorrs im getting are
Quote:
--------------------Configuration: complete op overload - Win32 Debug--------------------
Compiling...
Main.cpp
Linking...
Main.obj : error LNK2001: unresolved external symbol "bool __cdecl operator>(double const &,class cBox)" (??O@YA_NABNVcBox@@@Z)
Debug/complete op overload.exe : fatal error LNK1120: 1 unresolved externals
Error executing link.exe.
complete op overload.exe - 2 error(s), 0 warning(s)
Iv'e tried google and msdn and I can't find an answer.
[EDIT] Sorry about the formmating in the Source tags. I don't know how to make it better.