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 {};
?
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 {};
?
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.