宁波网站设计公司哪个好,直播电商平台开发,seo怎么做排名,wordpress如何更改会员中心一元运算符只对一个操作数进行操作#xff0c;下面是一元运算符实例#xff1a; 递增运算符#xff08;#xff09; 和递减运算符#xff08;--#xff09;一元减运算符#xff0c;即符号#xff08;-#xff09;逻辑非运算符#xff08;!#xff09;/***
overone.c… 一元运算符只对一个操作数进行操作下面是一元运算符实例 递增运算符 和递减运算符--一元减运算符即符号-逻辑非运算符! /***
overone.cpp
***/
#includeiostream
using namespace std;class Distance
{private:int feet;int inches;public:Distance(){feet 0;inches 0;}Distance(int f,int i){feet f;inches i;}void displayDistance(){cout F: feet I: inches endl; }Distance operator- (){feet -feet;inches -inches;return Distance(feet,inches);}
};int main()
{Distance D1(11,10), D2(-5,11);-D1;D1.displayDistance();-D2;D2.displayDistance();return 0;
} 运算结果 exbotubuntu:~/wangqinghe/C/20190808$ g overone.cpp -o overone exbotubuntu:~/wangqinghe/C/20190808$ ./overone F: -11 I: -10 F: 5 I: -11 转载于:https://www.cnblogs.com/wanghao-boke/p/11319647.html