C++友元函数的使用学习笔记
2013-10-19 23:44
267 查看
#include <iostream> #include <cmath> /* run this program using the console pauser or add your own getch, system("pause") or input loop */ using namespace std; class Point{ private: int X,Y; public: Point(double xx,double yy){ X=xx; Y=yy; } double GetX(){ return X; } double GetY(){ return Y; } friend double distances(Point&,Point&); }; double distances(Point& a,Point& b){ double dx= a.X-b.X; double dy =a.Y-b.Y; return sqrt(dx*dy+dy*dy); } int main(int argc, char** argv) { Point p1(1.0,2.0),p2(3.0,4.0); cout<<distances(p1,p2)<<endl;; return 0; }
相关文章推荐
- C++学习笔记四——何时使用引用参数
- C++ 学习笔记(2) 虚函数的使用 virtual
- C++学习笔记(七):string类用法及使用大全——在C++11下的使用详解
- 学习笔记----C++ 中iomanip头文件的使用
- [学习笔记][C++Primer Plus]String类的使用
- C++学习笔记7,const关键字的使用(一)。
- 【C++学习笔记】12_指针的定义与使用
- C++学习笔记,关于一个文件中的全局变量在其他文件中的使用
- 【C++学习笔记】友元函数和友元类
- 使用c++开发学习笔记
- C++学习笔记之1:使用相同形式的new和delete
- Windows编程 C++ DLL编程 学习笔记(一)静态链接库的创建和使用
- 1.JAVA中使用JNI调用C++代码学习笔记 - 星云博客园
- [学习笔记][C++Primer Plus]使用cout格式化输出字符串
- C/C++ 学习笔记:C++ 中 string 类使用总结
- 【VS2010学习笔记】【编程实例】 (在Visual Studio中使用C++创建和使用DLL)
- C++/GDI+ 学习笔记(一)——安装、配置&使用
- c++学习笔记 友元函数与友元类s
- C++学习笔记(八):对字符的操作函数和范围for语句的使用
- C++/GDI+ 学习笔记(一)——安装、配置&使用