friend function
来源:互联网 发布:尚学堂java 编辑:程序博客网 时间:2024/05/13 16:16
//============================================================================
// Name : friend.cpp
// Author :
// Version :
// Copyright : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================
#include <iostream>
#include<cmath>
#include<math.h>
using namespace std;
class Point {
private:
double x, y;
public:
Point(double x, double y) {
this->x = x;
this->y = y;
}
double getX() {
return x;
}
double getY() {
return y;
}
friend double Distance(Point &a, Point &b);
};
double Distance(Point &a, Point &b) {
double dx = a.x - b.x;
double dy = a.y - b.y;
return sqrt(dx * dx + dy * dy);
}
int main() {
Point a(3, 4), b(5, 6);
cout << Distance(a, b);
return 0;
}
// Name : friend.cpp
// Author :
// Version :
// Copyright : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================
#include <iostream>
#include<cmath>
#include<math.h>
using namespace std;
class Point {
private:
double x, y;
public:
Point(double x, double y) {
this->x = x;
this->y = y;
}
double getX() {
return x;
}
double getY() {
return y;
}
friend double Distance(Point &a, Point &b);
};
double Distance(Point &a, Point &b) {
double dx = a.x - b.x;
double dy = a.y - b.y;
return sqrt(dx * dx + dy * dy);
}
int main() {
Point a(3, 4), b(5, 6);
cout << Distance(a, b);
return 0;
}
- friend function
- friend class & function
- friend function in C++
- c++中friend function
- C++ friend function and friend class
- C++中friend的使用(friend function and friend class)
- C++中friend的使用(friend function and friend class) .
- C++中friend的使用(friend function and friend class)
- C++中friend的使用(friend function and friend class)
- C++中friend的使用(friend function and friend class)
- C++中friend的使用(friend function and friend class)
- c++ operator定义为friend function
- C++ friend template operator overload function
- C++ -- operator定义为friend function
- [C++] C++中friend的使用(friend function and friend class)
- friend
- friend
- Friend
- Android4.0系统接收不到广播的问题解析
- UVA 10494 - If We Were a Child Again(大数与整型相除取整和取余)
- 百度地图API详解之地图初始化
- javascript framework
- 这两天看了下谢略的权限管理系统有想法做一个。。
- friend function
- ORA-00845: MEMORY_TARGET not supported on this system
- 百度地图API详解之移动平台开发的最佳实践
- 帝国cms的最新漏洞是什么
- C语言的指针
- MySQL rand函数实现随机数的方法
- 学习总结及技巧
- 百度地图API详解之地图API加载方式
- Qt4之动态加载Ui 窗体控件