c++ 类成员变量 初始化赋值 多种方法

2023-12-29 19:38:03
class Okex {
public:
    int poolSize;
    int poolSize1;
    int poolSize2;
}

1

Okex::Okex() {
    poolSize = 10;
    poolSize1 = 15;
    poolSize2 = 100;
}

2

Okex::Okex() {
    initPoolSizes();
}

void Okex::initPoolSizes() {
    poolSize = 10;
    poolSize1 = 15;
    poolSize2 = 100;
}

3

Okex::Okex(int size1 = 10, int size2 = 15, int size3 = 100) {
    poolSize = size1;
    poolSize1 = size2;
    poolSize2 = size3;
}

4

Okex::Okex() : poolSize(10),poolSize1(15),poolSize2(100) {
}

文章来源:https://blog.csdn.net/tenc1239/article/details/135296116
本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。