C++: Differences between C++ and C#

Posted February 27, 2006 by William_Wilson in Computer programming

Last Updated on

The key differences between C# and C++ are explained in the following tech recipe.

Though C++ and C# are quite similar, there are some very key and major differences. In fact, I find C# resembles the style of java more than that of C++ in many ways.

(I will be following this up with some coding tutorials to hopefully start a C++ tech-recipe thread.)

Method/Function Declarations:
Constructor() { }
void aMemberFunction() { }
void aFunctionDeclaration();
void someOtherFunction() { }
int aVariable;

private aVariable;
public void aMemberFunction() { }
public void aFunctionDeclaration();
private void someOtherFunction() { }

Class Declaration
(For those who know what a managed class is):
__gc class A_Class{ };
*NOTE that C++ classes end with a ;.

automatically done so:
class A_Class{ }

This will allow multiple inheritance. [e.g., allows a method to be overridden many times in subclasses (derived classes)].

This will support inheritance, but not multiple (only one override per method/function/).

This allows header files and other class files to be included using the #include keyword.

This does not have such a quality, but the using directive allows other types to be referenced from another class (namespace as it is formerly called) without declaring its context.

Switch: *Props to PCurd for pointing out my careless mistake
This supports the switch statement and fall through.

This does not support fall through in the switch statement, and I have not discovered any replacement.

*These are the largest of the differences I have noticed so far. If I find any other impending differences, I will be sure to add them.

Questions/Comments: [email protected]
-William. ยง (marvin_gohan)

The Conversation

Follow the reactions below and share your own thoughts.

Leave a Reply