| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 786 人关注过本帖
标题:大家帮我看看这个题啊
只看楼主 加入收藏
luckygxboy
Rank: 1
等 级:新手上路
帖 子:8
专家分:0
注 册:2005-3-27
收藏
 问题点数:0 回复次数:1 
大家帮我看看这个题啊

头文件: #include <iostream> using namespace std; class qqq {public: qqq():real(0),imag(0){} qqq(int x,int y):real(x),imag(y){} qqq operator+(qqq&c2); friend ostream&operator<<(ostream&,qqq&); private: double real; double imag; }; 实现: #include "stdafx.h" #include <iostream> #include "qqq.h" using namespace std;

qqq qqq::operator +(qqq &c2) {return qqq(real+c2.real,imag+c2.imag); }

ostream&operator<<(ostream&output,qqq&c) {output<<c.real<<c.imag<<endl; return output; } 编译的时候说是 重载〈〈不能用类qqq的私有成员 可是我已经把它声明成friend的啦?

搜索更多相关主题的帖子: private include public double 
2005-04-29 14:06
luckygxboy
Rank: 1
等 级:新手上路
帖 子:8
专家分:0
注 册:2005-3-27
收藏
得分:0 

还有个题 头文件: #include <iostream> using namespace std; class complex {public: complex():real(0),image(0){} complex(float r,float i):real(r),image(i){} friend complex operator+(const complex&,const complex&); friend ostream&operator<<(ostream&,complex&); float cfabs(); //void write() const; private: float real; float image; }; 实现: #include "stdafx.h" #include <iostream> #include "complex.h" using namespace std;

complex operator+(const complex&x,const complex&y) { return complex(x.real+y.real,x.image+y.image); }

//void complex::write()const

ostream&operator<<(ostream&output,complex&t) {output<<"("<<t.real<<","<<t.image<<")"<<endl; return output; } 编译的时候说是类部连接错误 请问这是什么意思啊?

2005-04-29 14:10
快速回复:大家帮我看看这个题啊
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.020284 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved