编译通不过,那个地方错了呢? const后置为什么?

harderror harderror 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区

#include <iostream>
class point
{public:
point(float x=0,float y=0);
void setPoint(float,float);
float getX() const {return x;}
float getY() const {return y;}
friend ostream & operator<<(ostream &,const point &);
protected:
float x,y;
};
point::point(float a,float b)
{x=a;y=b;}
point::void setPoint(float a,float b)
{x=a;y=b;}
point::ostream & operator<<(ostream &output,const point &p)
{output<<"["<<p.x<<","<<p.y<<"]"<<endl;
return output;}

int main()
{Point p(3.5,6.4);
cout<<"x="<<p.getX()<<",y="<<p.getY()<<endl;
p.setPoint(8.5,6.8);
cout<<"p(new):"<<p<<endl;
}
...全文

相关推荐

评论 7
收藏 已收藏
分享
返回顶部
harderror
C++ 语言 65,212 成员 250,513 内容