C ++ - struct对类 [英] C++ - struct vs. class
问题描述
可能的重复项:
C / C ++ Struct与类
什么是C ++中的POD类型?
$ b
在 C ++在实验室书中,第6章:类中,在访问说明符
在类定义中,成员和基类的默认
访问是
private。在结构体定义中,
的缺省值是public。 这是类和
结构之间唯一的
区别,尽管按照惯例,一些
程序员只为 POD
类使用struct 。
:
- 类和结构之间不存在另外的区别,因为结构体不包含函数,只保存数据?
- 什么是POD类?而且,这里的所有其他课程是什么意思?
谢谢。
其他区别是
模板< class T& ...
,但
template< struct T> ...
不是。
Possible Duplicates:
C/C++ Struct vs Class
What are POD types in C++?
Hi,
In the C++ In a Nutshell book, in chapter 6: classes, unders Access specifiers, mentioned the following:
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.
My questions here are:
- Isn't there another difference between classes and structs in that structs don't hold functions and just hold data?
- What are POD classes? And, what is meant by all other classes here? Are there then special classes?
Thanks.
The other difference is that
template<class T> ...
is allowed, but
template<struct T> ...
is not.
这篇关于C ++ - struct对类的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!