第二十六讲 运算符重载2(课件+源代码)
《C++快速入门》026 - 课件+典型例题源代码本讲教学视频下载地址:运算符重载2 -《C++快速入门》026
附件包含:课件+典型例题源代码
注:VIP会员享有免费下载本站所有资源的特权!
友情提示:通过购买鱼C光盘(具体内容)赞助鱼C工作室均可加入VIP会员^_^
小甲鱼老师每天都熬夜吧,我猜的。。。辛苦了[咖啡]。。。
http://bbs.fishc.com/xwb/images/bgimg/icon_logo.png 来自 查鲁恩 的新浪微博 20鱼币啊 好贵哦:@ 课件只更新到26课吗?:D 努力跟著視頻打轉太快了...看不到一些部份 小甲鱼卖的东西都好贵啊 谢谢分享,来支持下~~~ 得多灌水了这样才有钱下课件 激动人心,无法言表!{:1_1:} 我不得不顶了……真是被感动的痛哭流涕……好贵的说,没鱼币了 :huffy:太生气了,无法HOLD啦 >_<...... 没有钱买啊没有鱼币啊
真是难得给力的帖子啊。 好贵、、、看来得要常混坛论啊 强烈支持楼主ing……26讲的程序有点小错误唉,加法那里应该是a*d+c*b 强烈支持楼主ing…… 好贵啊。。 +10086++++++++++++++++++++++++
#include <iostream>
using namespace std;
class Complex
{
public:
Complex();
Complex(double r,double i);
Complex operator-(Complex &d);
void print();
private:
double real;
double imag;
};
Complex::Complex()
{
real=0;
imag=0;
}
Complex::Complex(double r,double i)
{
real=r;
imag=i;
}
Complex Complex::operator-(Complex &d)
{
Complex c;
c.real=real+d.real;
c.imag=imag+d.imag;
return c;
}
void Complex::print()
{
std::cout<<"("<<real<<","<<imag<<"i)\n";
}
int main(int argc, char *argv[])
{
Complex c1(3,4),c2(5,-10),c3;
c3=c1-c2;
std::cout<<"c1= ";
c1.print();
std::cout<<"c2= ";
c2.print();
std::cout<<"c1+c2= ";
c3.print();
return 0;
} 好贵呀 水水水水
页:
[1]
2