5-14
来源:互联网 发布:电脑软件突然消失 编辑:程序博客网 时间:2024/04/29 06:26
#include<iostream.h>
class car;
class boat
{
public:
boat(double bw):bw(0){}
void setbw(double );
friend void totalweight(boat &a,car & b);
private:
double bw;
};
class car
{
public:
car(double cw):cw(0){}
void setcw(double );
friend void totalweight(boat &a,car & b);
private:
double cw;
};
void boat::setbw(double x)
{
bw=x;
}
void car::setcw(double y)
{
cw=y;
}
void totalweight(boat &a,car & b)
{
cout<<"output the total weight of the boat and the car "<<a.bw+b.cw<<endl;
}
void main()
{
double cw,bw;
boat b(20);
car m(10);
totalweight(b,m);
cout<<"input the boat weight"<<endl;
cin>>bw;
b.setbw(bw);
cout<<"input the car weight"<<endl;
cin>>cw;
m.setcw(cw);
totalweight(b,m);
}
熟悉友元函数的使用。
- 5-14
- 5-14
- XML2010-5-14
- 14--5--2Fun
- 14--5运用gets
- 14-5字符串统计
- 2014-5-14
- 14分析5
- 2016-5-14总结
- 2016/5/14
- Module 14 OVOW7.5 Tools
- 2012-5-14 知识总结
- 一起学WF3.5【14】
- 14--5--1 Fun而已
- 13-14寒假作业5
- week11---5月14日
- Holding Your Object 5-14
- 5-14 电话聊天狂人
- 关于友情
- C语言之Main函数返回值问题
- C#多线程应用技术入门实例
- 可变分区方式下的最优适应调度算法(C++环境下实现)
- C# 多线程中集合数据同步
- 5-14
- .NET Pet Shop 4:将 ASP.NET 1.1 应用程序迁移到 2.0
- C# 多线程访问UI
- 语义分析课程设计
- 6-25
- 华为面试感想
- petshop4.0 详解
- pan's labyrinth
- 【Discrete Mathematics】Template Method Pattern