C++ 默认构造函数

C++中class和struct除了空的默认构造函数,还存在传入初始化列表的默认构造函数。

使用方式为:

struct s
{
  int a,b;
  double c;    
}

int main()
{
  s s1={1,1,1.1};  
}
View Code

但是在类内如果提供了构造函数,则不会生成默认构造函数。

 

posted @ 2022-06-06 20:14  80k  阅读(291)  评论(0)    收藏  举报