/*
 * 由SharpDevelop创建。
 * 用户: jinweijie
 * 日期: 2015/10/28
 * 时间: 9:15
 * 
 * 要改变这种模板请点击 工具|选项|代码编写|编辑标准头文件
 */
using System;

namespace Study
{
    class Fraction
    {
        int first;
        int second;
        public Fraction()
        {
        }
        public Fraction(int first,int second)
        {
            this.first = first;
            this.second = second;
        }
        public static Fraction operator +(Fraction lhs,Fraction rhs)
        {
            Fraction f = new Fraction();
            f.first = lhs.first + rhs.first;
            f.second = lhs.second + rhs.second;
            return f;
        }
        public void Display()
        {
            Console.WriteLine("first={0}  second={1}",first,second);
        }
    }
    class Program
    {
        public static void Main(string[] args)
        {
            Console.WriteLine("Hello World!");
            
            // TODO: Implement Functionality Here
            Fraction  f1 = new Fraction(1,2);
            Fraction f2 = new Fraction(3,4);
            Fraction f3 = f1 + f2;
            f3.Display();
            
            
            Console.Write("Press any key to continue . . . ");
            Console.ReadKey(true);
        }
    }
}

operator的更多相关文章

  1. 孙鑫视频学习:“operator +=” 不明确的问题解决方法

    在基于单文档应用程序的MFC程序中,在OnChar函数中使用m_strLine+=nChar时,出现了error C2593:“operator +=”不明确的错误,经百度,找到如下解决方法,亲测可用 ...

  2. operator <<”不明确

    在声明重载的输出运算符<< 时,如果声明时的返回类型是std::ostream,而不是std::ostream&,但是定义的时候又加了引用的话,那么就会报“operator < ...

  3. error 2593 operator << 不明确的可能的解决方法

    编译Martinez算法时遇到该问题,提示重载的<<操作符调用不明确. 解决方法为:在cpp文件中将重载的该操作符的实现前添加完整的命名空间路径.

  4. The Safe Navigation Operator (&.) in Ruby

    The most interesting addition to Ruby 2.3.0 is the Safe Navigation Operator(&.). A similar opera ...

  5. Blender 脚本之 Operator 初探

    addon(插件)用来扩展 Blender 的功能,跟其他软件里的 plugin(插件)一样,去掉不会影响软件的运行.插件可以加到 Blender 的用户偏好设置目录里,或者就在你所编辑的.blend ...

  6. Sequence Project Showplan Operator 序列映射运算符

    Sequence Project Showplan Operator 序列映射运算符 序列映射运算符会从一个已经排序的集合里通过不停添加集合里的列执行计算. 运算符根据一个或多个列的值把输入集合分为多 ...

  7. [c++] Operator overloading

    c++的操蛋属性:自己为一档,空一档,其他随意. UB_stack a; UB_stack b = a; // copy auto c = a; auto d {a}; // (or auto d = ...

  8. EC笔记:第二部分:11:在operator=中处理“自我赋值”

    已经一年半没有写过博客了,最近发现学过的知识还是需要整理一下,为知笔记,要开始收费了以前写在为知笔记上笔记也会慢慢的转到博客里. 话不多说,进入正题. 考虑考虑以下场景: 当某个对象对自身赋值时,会出 ...

  9. Swift学习(一):自定义运算符 operator

    自定义运算符仅能包含这些字符: / = - + * % < >!& | ^.~ 运算符位置: 前置运算符 prefix 中间运算符 infix 后置运算符 postfix 运算符其 ...

  10. Bash 4.4 中新增的 ${parameter@operator} 语法

    Bash 4.4 中新增了一种 ${...} 语法,长这样:${parameter@operator}.根据不同的 operator,它展开后的值可能是 parameter 这个参数的值经过某种转换后 ...

随机推荐

  1. PyCharm 远程连接linux中Python 运行pyspark

    PySpark in PyCharm on a remote server 1.确保remote端Python.spark安装正确 2.remote端安装.设置 vi /etc/profile添加一行 ...

  2. Kibana安装及部署

    安装及部署 一.环境配置 操作系统:Cent OS 7 Kibana版本:3.1.2 JDK版本:1.7.0_51 SSH Secure Shell版本:XShell 5 二.操作过程 1.下载指定版 ...

  3. common.support.percent.PercentFrameLayout.onLayout(PercentFrameLayout.java:151)

    08-29 20:01:47.402 18908-19364/com.tongyan.subway.inspect E/CrashHandler: java.lang.NullPointerExcep ...

  4. Oracle死锁产生的原因和解决办法

    如果有两个会话,每个会话都持有另一个会话想要的资源,此时就会发生死锁.用下面实验来说明死锁的产生原因和解决办法.SESSION1:SQL> create table t2 as select * ...

  5. iframe自适应高度(兼容IE 火狐 谷歌)

    <div id="leamain"> <iframe src="#" marginheight="0" marginwid ...

  6. 洛谷P3367 【模板】并查集

    P3367 [模板]并查集 293通过 551提交 题目提供者HansBug 标签 难度普及- 提交  讨论  题解 最新讨论 不知道哪错了 为啥通不过最后三个节点 题解 不懂为什么MLE 最后一个数 ...

  7. express html模板项目搭建

    初学express的亲们,估计要弄ejs和jade会比较烦躁,那就先html开始,简单笔记如下:   1.新建项目文件夹demotest 2.进入demotest    >express -e ...

  8. 2016-06-06:X264码率控制

    H.264与x264 H264是一个视频压缩编码标准.https://zh.wikipedia.org/wiki/H.264/MPEG-4_AVC X264实现H264视频压缩标准的开源项目.http ...

  9. 常用vim设置

    set tabstop=4set shiftwidth=4set expandtabset hlsearchset cindent set autoindent set tabstop=4是设TAB宽 ...

  10. mac 下 chrome 语言环境 设置

    当然,如果把系统语言更改为英文,Chrome.QQ 等一系列软件会自动变成英文界面,而且没有提供切换语言的设置. 啪了下 Google,找到了方法,直接在终端运行后重启 Chrome 即可更改. 英文 ...