Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

C++/CLI interface class vs. interface struct

Tags:

c++-cli

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

public interface class IC {};

public interface struct IS {};

Similar situations:

public enum class EC {};

public enum struct ES {};

?

like image 851
Marc Andreson Avatar asked Jul 29 '10 19:07

Marc Andreson


2 Answers

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.

like image 137
Reed Copsey Avatar answered Oct 22 '22 07:10

Reed Copsey


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.

like image 1
Will Dean Avatar answered Oct 22 '22 09:10

Will Dean