C++第三次作业
来源:互联网 发布:淘宝最稀奇暴利产品. 编辑:程序博客网 时间:2024/06/05 16:04
友元函数
#include<iostream.h>
#include<cmath>
class Long
{
private:
double x;
double y;
public:
Long(double xx=0,double yy=0):x(xx),y(yy){}
void distance1(Long &);
friend void distance2 (Long &,Long &);
int getx()
{
return x;
}
int gety()
{
return y;
}
};
void Long::distance1(Long &t)
{
cout<<sqrt((this->x-t.x)*(this->x-t.x)+(this->y-t.y)*(this->y-t.y))<<endl;
}
void distance2 (Long &t1,Long &t2)
{
cout<<sqrt((t1.x-t2.x)*(t1.x-t2.x)+(t1.y-t2.y)*(t1.y-t2.y))<<endl;
}
void distance3 (Long &t1,Long &t2)
{
cout<<sqrt((t1.getx()-t2.getx())*(t1.getx()-t2.getx())+(t1.gety()-t2.gety())*(t1.gety()-t2.gety()))<<endl;
}
int main()
{
Long L1(4,6),L2(2,3);
L1.distance1(L2);
distance2(L1,L2);
distance3(L1,L2);
return 0;
}
- c语言作业第三次
- 第三次c程序作业
- 第三次C语言程序设计作业
- C语言第三次作业
- 第三次C程序语言设计作业
- c语言程序设计第三次作业 2
- 第三次C程序课堂作业
- C语言第三次课堂作业
- 第三次c程序课后作业
- C语言程序设计第三次课堂作业
- C语言第三次作业练习
- 第三次作业
- 第三次作业
- 第三次作业
- 第三次作业
- 第三次作业
- 第三次作业
- 第三次作业
- android容联云IM初始化介绍及简单登陆修改
- Could not connect: Connection using old (pre-4.1.1) authentication protocol
- 实战录 | 基于redis的分布式HA调度器解决方案
- Auto property synthesis will not synthesize property ‘delegate’;it will be implemented by its superc
- android之Intent的七大属性
- C++第三次作业
- ccah-500 第42题 want to set and enforce a block size of 128MB for all new files written to the cluster
- C# 程序员最常犯的 10 个错误
- OPenCV floodfill 泛洪填充的使用方法
- 第三章 DispatcherServlet详解 ——跟开涛学SpringMVC
- 工作中Tortoise SVN遇到的一个问题,Commit failed (details follow): Authorization failed
- HTML5+javascript记录
- maven私服问题
- Java与Struts结合写一个简单基础的分页显示