【问题标题】:How to initialize tm struct memebers in initializer list of a structure in C++ 98 standard如何在 C++ 98 标准结构的初始化列表中初始化 tm struct 成员
【发布时间】:2022-01-11 17:52:32
【问题描述】:

我正在尝试使用初始化列表初始化 ::tm 结构的成员,如下所示。但这只有在 C++ stds > 98 时才有可能。

如何在 C++ 98 中实现相同的功能?

struct abc {
    abc () : time_struct_{0,0,0,0,0,0,0,0,0}, x(0) { }
    ::tm time_struct_ ;
    int x;
};
 

【问题讨论】:

  • 不应该time_struct_()对其所有成员进行零初始化吗?
  • @DanielLangr,它确实初始化了。谢谢!

标签: c++ struct initializer-list c++98


【解决方案1】:

正如Daniel Langr 提到的time_struct_() 所做的那样。

【讨论】:

  • 这看起来像是评论,而不是对问题的直接回答。您可以考虑下次将此添加为评论,而不是将其作为答案发布。
猜你喜欢
  • 2011-05-11
  • 1970-01-01
  • 1970-01-01
  • 2011-12-01
  • 1970-01-01
  • 2011-07-14
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多