Hey all,
I'm trying to compile some example source code from my MCSE coursework, which is supposed to demonstrate the use of operator overloading. Problem is, VC++ 6.0 SP5 dies. Here's the error I get:
D:\MCSE\Book2\Chapter11\5.cpp(48) : fatal error C1001: INTERNAL COMPILER ERROR
(compiler file 'msc1.cpp', line 1794)
Please choose the Technical Support command on the Visual C++
Help menu, or open the Technical Support help file for more information
Error executing cl.exe.
Now here's the code:
Code:
#include <iostream.h>
class Coordinates
{
protected:
int xcoord, ycoord;
public:
Coordinates(void);
Coordinates(int x1, int y1);
Coordinates operator + (Coordinates inCoord);
Coordinates operator - (Coordinates *inCoord);
void show(void);
};
int main(void)
{
Coordinates Coord1(10, 10), Coord2(2, 2);
Coordinates Coord3, Coord4;
cout << "Here are the current values of Coord 1 and 2:\n";
Coord1.show();
Coord2.show();
Coord3 = Coord1 + Coord2;
Coord4 = Coord1 - &Coord2;
cout << "Coord1 + Coord2:\n";
Coord3.show();
cout << "Coord1 - Coord2:\n";
Coord4.show();
return 0;
}
Coordinates::Coordinates(void)
{
xcoord = 0;
ycoord = 0;
}
Coordinates::Coordinates(int x1, int y1)
{
xcoord = x1;
ycoord = y1;
}
Coordinates::Coordinates::operator + (Coordinates inCoord)
{
Coordinates temp_coord;
temp_coord.xcoord = xcoord + inCoord.xcoord;
temp_coord.ycoord = ycoord + inCoord.ycoord;
return temp_coord;
}
Coordinates::Coordinates::operator - (Coordinates *inCoord)
{
Coordinates temp_coord;
temp_coord.xcoord = xcoord - inCoord->xcoord;
temp_coord.ycoord = ycoord - inCoord->ycoord;
return temp_coord;
}
void Coordinates::show(void)
{
cout << "Value of X coordinate: " << xcoord << endl
<< "Value of Y coordinate: " << ycoord << endl;
}
After some digging around, I managed to find this Microsoft Knowledge Base Article outlining the problem. However, to be perfectly honest, classes are so new to me, that I don't really know exactly how to fix the problem.
I've tried a few different things with the code now, all of which end up with the same error. Does anyone mind taking a quick look through? I'd be very grateful.
Thanks in advance,
John.