开发者

C++/CLI interface class vs. interface struct

What is the difference between the following declarations (in C++/CLI):

public interface class IC {};

public interface struct IS {};

Similar situation开发者_C百科s:

public enum class EC {};

public enum struct ES {};

?


They are identical.

For details, see MSDN's interface class reference, under Remarks:

interface struct is equivalent to interface class.


I believe Microsoft decided to allow both options just to keep consistency with ref class/ref struct and value class/value struct. However, since interfaces don't have private members, for interface, the two statements become exactly the same.


There's no difference. They're equivalent.

Bear in mind than in 'real' C++ there's actually almost no difference between struct and class, other than the default accessibility of members. So in the parallel universe of C++/CLI, where accessibility rules are different anyway, it's not completely mad that they're equivalent.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜