-->
当前位置:首页 > 题库

PROGRAMMING:Practice of friend function

Luz5年前 (2021-05-10)题库414
Define two classes: boat and car, both of which have private integer weight attributes. Define a friend function gettotalweight () of both classes to calculate the weight sum of them.
Reference main function:
int main()
{
int n,m;
cin>>n>>m;
Boat boat(n);
Car car(m);
Cout < "total weight of ship and car" < gettotalweight (boat, car) < "ton" < endl;
}
###Input format:
Please write the input format here. For example: input 2 integers m and N in one line.
###Output format:
Please describe the output format here. For example: for each group of input, output in a row: ship and car total weight m + n tons.
###Input example:
Here is a set of inputs. For example:
```in
40 30
```
###Output example:
The corresponding output is given here. For example:
```out
The ship and the car weigh 70 tons
```







answer:If there is no answer, please comment