| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 709 人关注过本帖
标题:求高手帮忙! c++ 问题?
取消只看楼主 加入收藏
DreamSkyCC
Rank: 2
来 自:河北赵县
等 级:论坛游民
帖 子:40
专家分:58
注 册:2010-11-28
结帖率:100%
收藏
已结贴  问题点数:2 回复次数:0 
求高手帮忙! c++ 问题?
求高手帮忙! c++ 问题?
#include <iostream>
using namespace std;
class Complex
{
    private:
  
        float Real,Image;
    public:
     
        Complex(float r = 0,float i = 0)
        {
            Real = r;
            Image = i;
     
        }
  
        void Show(int i)
        {
            cout<<"c"<< i << "=" << Real << "+" << Image << "i" << endl;
         
        }
        Complex operator+ (Complex &c);
     
        Complex operator- (Complex &c);
     
        void operator= (Complex &c);         

  
};
void Complex::operator= (Complex &c)
{
  
  

    Real = c.Real;
    Image = c.Image;
    return ;  

}
Complex Complex::operator+ (Complex &c)
{
  
    Complex t;
    t.Real = Real + c.Real;
    t.Image = Image + c.Image;
    return t;
}
Complex Complex::operator- (Complex &c)
{
  
    Complex t;
    t.Real = Real - c.Real;
    t.Image = Image - c.Image;
    return t;
}
int main(void)
{
    Complex c1(20,20),c2(30,50),c3;
    c1.Show(1);
    c2.Show(2);
    c3 = c1 + c2;
    c3.Show(3);
     

    return 0;
}
80: error: no match for ‘operator=’ in ‘c3 = (((Complex&)(& c2)))’
chongzai.cpp:36: note: candidates are: void Complex::operator=(Complex&)
搜索更多相关主题的帖子: class Complex private include 
2010-12-08 16:32
快速回复:求高手帮忙! c++ 问题?
数据加载中...
 
   



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

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