| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1133 人关注过本帖
标题:重載運算符為友元函數時出錯!!!! 急 在線等
取消只看楼主 加入收藏
lvyan
Rank: 1
等 级:新手上路
帖 子:49
专家分:0
注 册:2008-4-8
收藏
 问题点数:0 回复次数:0 
重載運算符為友元函數時出錯!!!! 急 在線等
可以重載為成員函數,但是當我重載為友元函數時就出錯.. 不知道哪們大蝦幫忙解釋一下.
以下是出錯信息:  
   --------------------Configuration: 1 - Win32 Debug--------------------
Compiling...
1.cpp
E:\VC\VC6CN\COMMON\MSDEV98\BIN\1\1.cpp(10) : fatal error C1001: INTERNAL COMPILER ERROR
        (compiler file 'msc1.cpp', line 1786)
         Please choose the Technical Support command on the Visual C++
         Help menu, or open the Technical Support help file for more information
执行 cl.exe 时出错.

1.exe - 1 error(s), 0 warning(s)


以下是程序:
#include<iostream>
using namespace std;
class Vector1
{  
    int x,y;
public:
    Vector1() {  };
    Vector1(int x1,int y1) { x=x1; y=y1; }
    friend Vector1 operator +(Vector1 v1,Vector1 v2)  //提示這裡有錯..
    {  Vector1 tmp;
      tmp.x=v1.x+v2.x;
      tmp.y=v1.y+v2.y;
      return tmp;
    }
   void disp()
   { cout<<"("<<x<<","<<y<<")"<<endl;
   }
};

void main()
{  Vector1 v1(6,8),v2(3,6),v3;
   v3=v1+v2;
   cout<<"v1+v2=";
   v3.disp();
}
搜索更多相关主题的帖子: 友元 算符 error Technical Support 
2008-05-30 00:22
快速回复:重載運算符為友元函數時出錯!!!! 急 在線等
数据加载中...
 
   



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

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