int ygxcalc(int r, int* area, int* circumference) 中的int r, int* area, int* circumference)可以写在不同一行吗
时间: 2023-08-28 07:08:42 浏览: 33
是的,可以写在不同的行。例如:
```
int ygxcalc(int r,
int* area,
int* circumference)
```
这种写法称为多行参数列表,可以增加代码的可读性。
相关问题
int ygxcalc(int r, int* area, int* circumference) 这括号里面的可以下面的行写吗
可以,但是要注意以下两点:
1. 如果要写在下一行,括号必须写在本行的末尾,不能单独占一行。
2. 如果你的编辑器支持自动对齐功能,建议按照常规写法,将括号与函数名写在同一行,并在下一行进行参数列表的书写。这样可以使代码更加美观易读。
例如:
```
int ygxcalc(int r, int* area, int* circumference)
{
// 函数体
}
```
设计一个circle类,包含半径(radius)属性,有三个公有成员函数:void init_r(int r)、float circumference()和float area().
好的,下面是一个简单的Circle类的设计:
```c++
class Circle {
public:
// 构造函数,初始化半径为
Circle() : radius() {}
// 初始化半径
void init_r(int r) {
radius = r;
}
// 计算周长
float circumference() {
return 2 * 3.14 * radius;
}
// 计算面积
float area() {
return 3.14 * radius * radius;
}
private:
int radius; // 半径
};
```
这个类包含一个私有成员变量radius,表示半径。构造函数初始化半径为。公有成员函数init_r用于初始化半径,circumference计算周长,area计算面积。
相关推荐
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)