c_cpp 在C ++中使用初始化列表

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了c_cpp 在C ++中使用初始化列表相关的知识,希望对你有一定的参考价值。

#include <iostream>

//uses initalization list

int getInt(int num){
    return num;
}


//struct with constructor and init list.
struct pair {
       int x;
       int y;
    pair(): x(2), y(2) {};
};

int main(){
    pair g;
    std::cout<< g.x << std::endl;
    return 0;
}

以上是关于c_cpp 在C ++中使用初始化列表的主要内容,如果未能解决你的问题,请参考以下文章

c_cpp 在C ++中使用无序地图

c_cpp 在C ++中使用无序地图

c_cpp 使用C ++库函数使用Suffix Array在文本中搜索模式

c_cpp 在c中使用strtod的例子

c_cpp 使用libcurl在C中获取html

c_cpp 使用void函数在C中进行递归