高手帮我看看程序,编译出错。
时间:2008-07-24 16:54:21
来源:论坛整理 作者: 编辑:chinaitzhe
//成员操作符
#include <iostream>
using namespace std;
class Point{
int x,y;
public:
void set(int a,int b){x=a,y=b;}
Point operator (const Point& d){
Point s;
s.set(x d.x,y d.y);
return s;
}
friend ostream& operator < <(ostream& o,const Point& d);
};
inline ostream& operator < <(ostream& o,const Point& d){
return o < <"(" < <d.x < <"," < <d.y < <")\n";
}
int main(){
Point s,t;
s.set(2,5);
t.set(3,1);
cout < <s t;
}
F:\vc \MSDev98\MyProjects\class 5\f0807.cpp(16) : error C2248: 'x' : cannot access private member declared in class 'Point'
F:\vc \MSDev98\MyProjects\class 5\f0807.cpp(5) : see declaration of 'x'
F:\vc \MSDev98\MyProjects\class 5\f0807.cpp(16) : error C2248: 'y' : cannot access private member declared in class 'Point'
F:\vc \MSDev98\MyProjects\class 5\f0807.cpp(5) : see declaration of 'y'
F:\vc \MSDev98\MyProjects\class 5\f0807.cpp(22) : error C2593: 'operator < <' is ambiguous
网友回复:public:
int x,y;
关键字:高手,看看,程序,编译,出错,
上一篇:map
下一篇:下面没有链接了











文章评论
共有 0 位网友发表了评论 此处只显示部分留言 点击查看完整评论页面