The December version of Visual Studio 2005 / C++ now has an internal access modifier instead of using public private. This is different from my previous post. The access modifiers public protected and protected private are still the same as before:
|C++ ||C# ||VB ||IL|
|public ||public ||Public ||public|
|protected ||protected ||Protected ||family|
|private ||private ||Private ||private|
|internal ||internal ||Friend ||assembly|
|public protected ||internal protected ||Protected Friend ||famorassem|
|protected private ||not possible ||not possible ||famandassem|
public public is no longer supported, too. public is good enough ;-)
As it was already announced, Christian Weyer did a great presentation (sponsored by INETA Europe) as can be seen from this feedback:
Christian also had a lot of fun:
C# has an internal access modifier (VB: Friend) to allow access only within the assembly. C++/CLI defines all access with the public/protected/private keywords; this allows more options:
|C++ ||C# ||VB|
| |public public |public ||Public|
| |protected protected |protected ||Protected|
| |private private |private ||Private|
| |public private |internal ||Friend|
|public protected ||internal protected ||Protected Friend|
|protected private ||not possible ||not possible|
With C++/CLI one access modifier defines the access within the assembly, the other one defines the outside access. The order doesn't matter: more access is always from inside. C# internal is done with C++/CLI public private: public within the assembly, private outside of the assembly. Protected within the assembly and private outside of the assembly is not possible with C#, but it is possible with C++/CLI.
C++/CLI was influenced by C#, but it also has a shorter syntax for properties.
This is the C# syntax of properties:
private string lastname;
public string Lastname
lastname = value;
The new C++/CLI syntax was influenced by C#:
property String^ Lastname
void set(String^ value)
lastname = value;
C++/CLI has another syntax for properties where just the value is set and returned that doesn't need so much typing:
property String^ Firstname;
With the property keyword a property and a field is generated automatically. This style is very useful if there's no extra verification of the value with the set accessor, and the value returned is not calculated. Let's write smaller code :-)
The variable that's behind the property is generated automatically. There's no need to know the name of the generated variable because the compiler knows when to optimize the code to use the variable instead of the property.
Some time ago we had a discussion about properties and fields in C# - this issue can be solved with the C++/CLI syntax for properties.
New groups with INETA Europe:
The first group in Bulgaria!