gpt4 book ai didi

C++ - 结构与类

转载 作者:IT老高 更新时间:2023-10-28 14:01:00 24 4
gpt4 key购买 nike

Possible Duplicates:
C/C++ Struct vs Class
What are POD types in C++?

嗨,

C++ In a Nutshell 一书中,在第6章:类中,在访问说明符下,提到了以下内容:

In a class definition, the default access for members and base classes is private. In a struct definition, the default is public. That is the only difference between a class and a struct, although by convention, some programmers use struct only for POD classes and use class for all other classes.

我的问题是:

  • 类和结构体之间是否还有另一个区别是结构体不保存函数而只保存数据?
  • 什么是 POD 类?而且,这里所有其他类是什么意思?那么有特殊类(class)吗?

谢谢。

最佳答案

另一个区别是

template<class T> ...

是允许的,但是

template<struct T> ...

不是。

关于C++ - 结构与类,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4791883/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com