为什么可以使用()初始化可变大小的对象,而不是在c++中使用{}中的对象。
为什么可以用括号初始化数组 nums ,而不能用牙套进行括号?这里有什么区别?我知道 nums 是可变大小的对象,不能初始化,但是我不确定为什么可以使用括号使用零来初始化它。
这行之有效:
int n = 5;
int nums[n]();
这无:
int n = 5;
int nums[n]{};
Why can initialize array nums with parentheses, but cannot with braces? Whats the difference here? I know nums is variable sized object and cannot be initialized, but I am not sure why it can be initialized with zeros using parentheses.
This works:
int n = 5;
int nums[n]();
This doesn't:
int n = 5;
int nums[n]{};
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论