lnk2019无法解析的外部命令"public:__thiscall" (一元运算符重载)

来源:互联网 发布:阳光房顶棚防水 知乎 编辑:程序博客网 时间:2024/05/28 11:48
#include <iostream>using namespace std;// "-"的重载//“++”的重载//重载方式1:友元函数的重载 2:成员函数的重载class Coordinate{public:Coordinate(int x , int y){mx = x;my = y;};~Coordinate(){};Coordinate& operator-(){ mx = -mx; my = -my; return *this;}//friend Coordinate& operator-(Coordinate& floor);int mx;int my;};int main(void){Coordinate coor(2, 5);-coor;//coor.operator-();cout << coor.mx <<"\n"<< coor.my << endl;system("pause");return 0;}
一元操作符重载
析构函数忘了添加 {}
报错 LNK2019
阅读全文
0 0