指派初始化器

C++20可以指派初始化器,可显示指明需初始化的成员变量,初始化部分成员变量。

#include 
#include 
#include 
using namespace std;

struct test
{
    int n;
    string str;
    double db;
};

int main()
{
    //c++11
    test t{1,"hello",3.14};
    cout<<"t:"<

指派初始化器_第1张图片

 

你可能感兴趣的:(c++20,c++)