的C结构和C ++结构
有谁请告诉我有什么主要区别
C&放大器之间; C ++结构。
Could anybody please tell me what is the main difference between C & C++ structures.
在C ++ 结构
和类
是同样的事情,不同的是结构默认为公共
的知名度和类默认为私人
可视性。
In C++ struct
and class
are the exact same thing, except for that struct defaults to public
visibility and class defaults to private
visiblity.
在C,结构名称是在自己的命名空间,所以如果你有结构美孚{};
,你需要写结构富富;
以创建该类型的变量,而在C ++中,你可以只写富富;
,虽然在C形式也是允许的。 C程序员通常会使用 typedef结构{}富;
允许变量定义的C ++语法
In C, struct names are in their own namespace, so if you have struct Foo {};
, you need to write struct Foo foo;
to create a variable of that type, while in C++ you can write just Foo foo;
, albeit the C style is also permitted. C programmers usually use typedef struct {} Foo;
to allow the C++ syntax for variable definitions.
C编程语言也不支持知名度的限制,成员函数或继承。
The C programming language also does not support visibility restrictions, member functions or inheritance.