回复 2楼 yangfrancis
能帮我看一下这个吗?谢谢。
#include "stdafx.h"
#include <iostream>
using namespace std;
class distance
{
public:
float inch;
float feet;
distance()
{
inch = 0;
feet = 0;
}
distance(float k, float t)
{
inch = k;
feet = t;
}
float displaydistance()
{
cout << "i= " << inch << endl;
cout << "f= " << feet << endl;
}
distance operator-()
{
inch = -inch;
feet = -feet;
return distance(inch, feet);
}
};
int main()
{
distance d1(11, 10), d2(-5, 11);
-d1;
-d2;
d1.displaydistance();
d2.displaydistance();
return 0;
}
每次系统都提示主函数的 'distance': ambiguous symbol。