L
LZXIA
Compiling...
overlaod.cpp
d:\vc work\cpp\think_in_cpp\chapter10\overlaod.cpp(17) : fatal error
C1001: INTERNAL COMPILER ERROR
(compiler file 'msc1.cpp', line 1786)
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.
overlaod.obj - 1 error(s), 0 warning(s)
when compiling, errors above will apear.I am a newbie in C++, I hope
someone here can help me.Following is my source code
#include <iostream>
using namespace std;
class myOverload
{
public:
myOverload(float a, float b)
{
x = a;
y = b;
}
myOverload operator=(const myOverload qq)
{
return myOverload(x = qq.x, y = qq.y);
}
friend const myOverload operator+(const myOverload &m, const
myOverload &n);
void myprint()
{
cout << "here is a complex: \n" << x << "+" << y << "i" << endl;
}
private:
float x;
float y;
};
myOverload const operator+(const myOverload &m, const myOverload &n)
{
return myOverload(m.x + n.x, m.y + n.y);
}
int main()
{
myOverload AA(1.3f, 2.6f);
myOverload BB(1.7f, 0.4f);
myOverload CC = AA + BB;
CC.myprint();
return 0;
}
overlaod.cpp
d:\vc work\cpp\think_in_cpp\chapter10\overlaod.cpp(17) : fatal error
C1001: INTERNAL COMPILER ERROR
(compiler file 'msc1.cpp', line 1786)
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.
overlaod.obj - 1 error(s), 0 warning(s)
when compiling, errors above will apear.I am a newbie in C++, I hope
someone here can help me.Following is my source code
#include <iostream>
using namespace std;
class myOverload
{
public:
myOverload(float a, float b)
{
x = a;
y = b;
}
myOverload operator=(const myOverload qq)
{
return myOverload(x = qq.x, y = qq.y);
}
friend const myOverload operator+(const myOverload &m, const
myOverload &n);
void myprint()
{
cout << "here is a complex: \n" << x << "+" << y << "i" << endl;
}
private:
float x;
float y;
};
myOverload const operator+(const myOverload &m, const myOverload &n)
{
return myOverload(m.x + n.x, m.y + n.y);
}
int main()
{
myOverload AA(1.3f, 2.6f);
myOverload BB(1.7f, 0.4f);
myOverload CC = AA + BB;
CC.myprint();
return 0;
}