a standard answer

guest (too late)
: The default member and base class access specifiers are different.

This is one of the commonly misunderstood aspects of C++. Believe it or not, many programmers think that a C++ struct is just like a C struct, while a C++ class has inheritance, access specifiers, member functions, overloaded operators, and so on. Some of them have even written books about C++. Actually, the C++ struct has all the features of the class. The only differences are that a struct defaults to public member access and public base class inheritance, and a class defaults to the private access specifier and private base class inheritance. Getting this question wrong does not necessarily disqualify you because you will be in plenty of good company. Getting it right is a definite plus.

2001-3-24 -04:00

回到话题: 我找工作面试时的一个问题,Struct和Class有什么区别?我回答Struct 没有构造和析构函数,现在想想一定不对,谁知道,谢谢先。

回到论坛: HOME枫下论坛枫下论坛主坛工作学习IT技术讨论