C语言对象初始化器

2019独角兽企业重金招聘Python工程师标准>>> hot3.png

C#对象初始化器:

class Sample
{
   public string Name;
   public string Sex;
}

Sample obj = new Sample()
{
  Name = "lzb",
  Sex  = "男"
};

C语言对象初始化器:

struct Sample
{
    char * Name;
    char * Sex;
};

struct Sample obj = 
{
    .Name = "lzb", //前面那个 . 表示当前对象
    .Sex  = "男"
};

 

转载于:https://my.oschina.net/tigerBin/blog/884714

你可能感兴趣的:(C语言对象初始化器)