码迷,mamicode.com
首页 > 其他好文 > 详细

重载类型运算符

时间:2019-04-18 20:17:59      阅读:108      评论:0      收藏:0      [点我收藏+]

标签:str   private   turn   运算   pac   类型   highlight   names   stream   

#include <iostream>

using namespace std;

class Complex
{
private:
    double real,imag;
public:
    Complex(double r=0,double i=0):real(r),imag(i){}
    operator double(){return real;}
    //返回类型为重载类型
    //double n=2+c;
    //double n=2+c.operator double();
}

  

重载类型运算符

标签:str   private   turn   运算   pac   类型   highlight   names   stream   

原文地址:https://www.cnblogs.com/-Asurada-/p/10731719.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!