/************************************************************************************************************** A Compared Overview of C++, C#, and Java Quick and rough comparisons of various features of C++, C#, and Java. Just for those built into the language itself, not capabilities supported by libraries. **************************************************************************************************************/ /* 1. Features overview C++ C# Java --------------------------------------------------------------------------------------------------------------- Array bounds checking N Y Y Built-in strings N Y Y Conditional compilation Y Y N Covariant return types Y N N Direct access to C Y N N Direct access to hardware Y N N Direct native code generation Y N N Dynamic class loading N N Y Enumerated types Y Y N Exception handling Y Y Y Explicit memory allocation control Y N N Function delegates N Y N Function overloading Y Y Y Garbage Collection N Y Y Generates standard object files Y N N Guaranteed initialization N Y Y Inline assembler Y N N Inner classes N N Y Interfaces Y(*) Y Y Independent of VM Y N N Lightweight arrays Y N N Lightweight objects Y Y N Macro text preprocessor Y N N Modules Y Y Y Multiple Inheritance Y N N Nested functions N N N Operator overloading Y Y N Out function parameters Y Y N Properties N Y N Static construction order N Y Y String switches N Y Y Templates Y N (*) N (*) Thread synchronization primitives N Y Y try-catch-finally blocks N Y Y Use existing debuggers Y N N --------------------------------------------------------------------------------------------------------------- 2. Keywords Notice, the same keyword may have subtle difference in different languages in a way. C++ C# Java --------------------------------------------------------------------------------------------------------------- abstract N Y Y as N Y N base N Y N bool Y Y N boolean N N Y break Y Y Y byte N Y Y case Y Y Y catch Y Y Y char Y Y Y checked N Y N class Y Y Y const Y Y Y const_cast Y N N continue Y Y Y decimal N Y N default Y Y Y delegate N Y N delete Y N N do Y Y Y double Y Y Y dynamic_cast Y N N else Y Y Y enum Y Y N extends N N Y event N Y N explicit Y Y N extern Y Y N false Y Y Y final N N Y finally N Y Y float Y Y Y for Y Y Y foreach N Y N friend Y N N goto Y Y Y(*) if Y Y Y implements N N Y implicit N Y N import N N Y in N Y N instanceof N N Y inline Y N N int Y Y Y interface N Y Y internal N Y N is N Y N lock N Y N long Y Y Y mutable Y N N namespace Y Y N native N N Y new Y Y Y null N Y Y object N Y N operator Y Y N out N Y N override N Y N params N Y N package N N Y private Y Y Y protected Y Y Y public Y Y Y readonly N Y N register Y N N ref N Y N reinterpret_cast Y N N return Y Y Y sbyte N Y N sealed N Y N short Y Y Y signed Y N N sizeof Y Y N stackalloc N Y N static Y Y Y static_cast Y N N strictfp N N Y super N N Y string N Y N struct Y Y N switch Y Y Y synchronized N N Y template Y N N this Y Y Y throw Y Y Y throws N N Y transient N N Y true Y Y Y try Y Y Y typedef Y N N typeof N Y N typeid Y N N typename Y N N uint N Y N ulong N Y N unchecked N Y N unsafe N Y N ushort N Y N union Y N N unsigned Y N N using Y Y N virtual Y Y N void Y Y Y volatile Y Y Y while Y Y Y --------------------------------------------------------------------------------------------------------------- 3. Operators C++ C# Java --------------------------------------------------------------------------------------------------------------- Addition + + + Subtraction - - - Multiplication * * * Division / / / Integer Division / Modulus % % % Assignment = = = Addition Assignment += += += Subtraction Assignment -= -= -= Multiplication Assignment *= *= *= Division Assignment /= /= /= Integer Division Assignment /= Modulus Assignment %= %= %= Left shift << << << Right shift >> >> >> Left shift assignment <<= <<= <<= Right shift assignment >>= >>= >>= Bitwise AND & & & Bitwise inclusive OR | | | Bitwise exclusive OR ^ ^ ^ Logical AND && && && Logical OR || || || Logical Negation ! ! ! Bitwise AND Assignment &= &= &= Bitwise exclusive OR Assignment ^= ^= ^= Bitwise inclusive OR Assignment |= |= |= One's Complement ~ ~ ~ Less than < < < Less than or equal to <= <= <= Greater than > > > Greater than or equal to >= >= >= Equality == == == Not equal != != != Compare reference type x is MyClass x instanceof MyClass Compare string some functions == or String.Equals() String.equals() concatenate string + + Scope resolution :: . and base Subscript [ ] [ ] [ ] Function call ( ) ( ) ( ) Type conversion (SomeType) and something else (SomeType) (SomeType) Member access . or -> . . Postfix increment ++ ++ ++ Postfix decrement -- -- -- Indirection * * (for unsafe code) Address-of & & (for unsafe code) Prefix increment ++ ++ ++ Prefix decrement -- -- -- Size of type sizeof sizeof Comma , , Conditional ?: ?: ?: Pointer-to-member .* or -> . (for unsafe code) Reference & --------------------------------------------------------------------------------------------------------------- 4. Simple escape sequences C++ C# Java --------------------------------------------------------------------------------------------------------------- \a Y Y N \b Y Y Y \f Y Y Y \n Y Y Y \r Y Y Y \t Y Y Y \v Y Y N \" Y Y Y \' Y Y Y \\ Y Y Y --------------------------------------------------------------------------------------------------------------- 5. Comments C++ C# Java --------------------------------------------------------------------------------------------------------------- \\ Y Y Y /* */ Y Y Y /** */ N N Y /// N Y N --------------------------------------------------------------------------------------------------------------- */