[c++]使用花括号初始化结构体

c++11中 可使用花括号直接初始化结构体,示例代码以下:ios #include<iostream> #include<string> struct TT{ int t1; std::string t2; }; int main(){ TT t{1,"hello"}; std::cout << t.t1 << ", " << t.t2 << std::endl
相关文章
相关标签/搜索