This topic has been archived. It cannot be replied.
-
工作学习 / IT技术讨论 / 我找工作面试时的一个问题,Struct和Class有什么区别?我回答Struct 没有构造和析构函数,现在想想一定不对,谁知道,谢谢先。
-paulzhou(alwaysbeginner);
2001-3-24
(#36734@0)
-
struct is for ADT. there is no function inside a struct.
class is for OOT, there are methods inside a class.
-wjiang(wjiang);
2001-3-24
(#36735@0)
-
面试就问这种问题?
-guest:我真冤;
2001-3-24
(#36736@0)
-
这道题看来是用来看看你是否知道(仅仅是知道,不是精通)C++
-guest:;
2001-3-24
(#36757@0)
-
Actually, the only different between Struct & Class is that: by default all members in Struct are public while they are private in Class.
Both of them can have member Variables and Functions(methods).
Ji Ang's answer is not proper.
-guest:Zack;
2001-3-24
(#36740@0)
-
you are right!
-guest:guest;
2001-3-24
(#36749@0)
-
Really? 我觉得Class 是为了OOP而将 Struct 改造过来 的,因此虽然 Struct里可以有 member function,但如果C编译器里就会出问题,而在C++ 编译器里就可以过去。所以关于 private 和 public 的问题我同意你的,但后面的解释我同意wjiang的。
-flying_snow(飞雪浮冰);
2001-3-24
(#36762@0)
-
I understand Zack's answer is the most important point. If supplemented with your answer, it is good enough.Of course, there are difference in the syntax. For such an open question, you just need enumerate the main points. If you could give some examples, however, you will kill a lot of time. By the way, if you could say something about the advantage of class over struct, you may show people that you are really object-oriented.
-jabber(jabber);
2001-3-24
{326}
(#36773@0)
-
Could anybody say something about the advantage of class over struct?
-deepyellow(DeepYellow);
2001-3-25
(#36912@0)
-
a standard answer
-guest:too late;
2001-3-24
{772}
(#36818@0)