c++相关的面向对象编程,只能使用c++,不能用c.语言,不知道为什么我自己写的总是有错误
3条回答 默认 最新
- CSDN专家-sinJack 2022-11-10 09:12关注
你写的代码发出来看看,帮你调试一下。
#include <iostream> #include<math.h> using namespace std; class MyPoint { private: double x; double y; public: MyPoint() { x=0; y=0; } MyPoint(double a,double b) { x=x; y=y; } double get_x() { return x; } void set_x(double a) { x=a; } void set_y(double a) { y=a; } double get_y() { return y; } double distance(MyPoint a) { double b; b=(x-a.get_x())*(x-a.get_x())+(y-a.get_y())*(y-a.get_y()); b=sqrt(b); return b; } }; int main() { Point a; Point b(10,30.5); double c; c=a.distance(b); cout<<"***********Extend MyPoint**********"<<endl; cout<<c; cout<<endl; return 0; }
本回答被题主选为最佳回答 , 对您是否有帮助呢?解决 无用评论 打赏 举报 编辑记录
悬赏问题
- ¥20 西门子S7-Graph,S7-300,梯形图
- ¥50 用易语言http 访问不了网页
- ¥50 safari浏览器fetch提交数据后数据丢失问题
- ¥15 matlab不知道怎么改,求解答!!
- ¥15 永磁直线电机的电流环pi调不出来
- ¥15 用stata实现聚类的代码
- ¥15 请问paddlehub能支持移动端开发吗?在Android studio上该如何部署?
- ¥20 docker里部署springboot项目,访问不到扬声器
- ¥15 netty整合springboot之后自动重连失效
- ¥15 悬赏!微信开发者工具报错,求帮改