标题:声明类函数operator+时,编译出错
取消只看楼主
ddsxd
Rank: 1
等 级:新手上路
帖 子:12
专家分:0
注 册:2007-3-22
 问题点数:0 回复次数:1 
声明类函数operator+时,编译出错
程序全文如下,编译时出错的行已经改成红色,错误描述为: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
这是怎么回事儿啊???
ps:编译器是VC6.0


#include <iostream>
using namespace std;
class Point
{
int x,y;
public:
void set(int a,int b)
{
x=a,y=b;
}
void print()const
{
cout<<'('<<x<<','<<y<<')\n';
}
friend Point operator +(const Point& a,const Point& b);
friend Point add(const Point& a,const Point& b);
}
Point operator+(const Point& a,const Point& b)
{
Point s;
s.set(a.x+b.x,a.y+b.y);
return s;
}
Point add(const Point& a,const Point& b)
{
Point s;
s.set(a.x+b.x,a.y+b.y);
return s;
}
void main()
{
Point a,b;
a.set(3,2);
b.set(1,5);
(a+b).print();
operator+(a,b).print();
add(a+b).print();
}

[此贴子已经被作者于2007-3-29 21:14:13编辑过]

搜索更多相关主题的帖子: operator 函数 声明 编译 
2007-03-29 20:44
ddsxd
Rank: 1
等 级:新手上路
帖 子:12
专家分:0
注 册:2007-3-22
得分:0 
谢谢!
帮了大忙了
2007-04-02 12:32



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-127873-1-1.html




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

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