友元函数
来源:互联网 发布:上市公司研发费用数据 编辑:程序博客网 时间:2024/05/23 11:05
#include <iostream>#include<cmath>using namespace std;class Cpoint{private: double x; double y;public: Cpoint(double xx=0,double yy=0):x(xx),y(yy){} void setx(double xx); void sety(double yy); double putx(); double puty(); friend void showCpoint(Cpoint &a,Cpoint &b);};void Cpoint::setx(double xx){ x=xx;}void Cpoint::sety(double yy){ y=yy;}double Cpoint::putx(){ return x;}double Cpoint::puty(){ return y;}void showCpoint(Cpoint &a,Cpoint &b){ double x=a.x-b.x; double y=a.y-b.y; cout<<sqrt(x*x+y*y)<<endl;}void show(Cpoint a,Cpoint b){ double x=a.putx()-b.putx(); double y=a.puty()-b.puty(); cout<<sqrt(x*x+y*y)<<endl;}int main(){ Cpoint a(3,3),b(1,1); show(a,b); showCpoint(a,b); return 0;}
0 0
- 友元函数
- 友元函数
- 友元函数
- C++友元函数
- 友元函数
- 友元函数
- 友元函数
- 友元函数
- 什么是友元函数
- 友元函数
- 友元函数(二)
- 友元函数
- 友元成员函数
- friend 友元函数
- 友元函数
- 友元函数 友元类
- 友元函数
- 模板友元函数
- xrandr命令解决ubuntu15.10双屏分辨率问题
- 网页监控之自己设计监控界面
- @property和@synthesize
- 一般时间函数
- Java生成六位验证码(发短信验证)
- 友元函数
- 对于web中导入自定义字体
- struts2项目插入中文到mysql数据库乱码的解决方法
- 大嘴巴 www.bigzb.com
- extern "C"
- JVM内存分配以及存储总结
- Mac OSX 10.9搭建nginx+mysql+php-fpm环境
- cocos2d-js 中scrollview详解
- 深入理解按位异或运算符