C++: Differences between C++ and C#
Key differences between C# and C++
It was a surprise that there was no thread for C++ recipes. Though C++ and C# are quite similar there are some very key and major differences.
-I find C# resembles the style of java more than that of C++ i many ways.
(I will be following this up with some coding recipes, to hopefully start a C++ reciped thread)
Method/Function Declarations:
C++ :
public:
Constructor() { }
void aMemberFunction() { }
void aFunctionDeclaration();
private:
void someOtherFunction() { }
int aVariable;
C#:
private aVariable;
public void aMemberFunction() { }
public void aFunctionDeclaration();
private void someOtherFunction() { }
Class Declaration:
For those who know what a managed class is:
C++ :
__gc class A_Class{ };
*NOTE that C++ classes end with a ;
C#:
automatically done so:
class A_Class{ }
Inheritence:
C++:
will allow multiple inheritence. eg. allows a method to be overriden many times in subclasses (derived classes).
C#:
supports inheritence, but not multiple, only 1 override per method/function/
Includes:
C++:
allows header files and other class files to be included using the #include keyword.
C#:
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 it's context.
Switch: *Props to PCurd for pointing out my careless mistake :)
C++:
supports the switch statement, and fall through.
C#:
does not support fall through in the switch statement, and i have not come across any replacement.
*These are the largest of the differences i have noticed so far, if i come across any further impending differences i will be sure to add them.
Questions/Comments: william_a_wilson@hotmail.com
-William. (marvin_gohan)
Also see ...
H3How to Overload the common operators: =, +, , */H3POverloading an operator allows for custom operations on your own objects. br /*Say you want to add to person objects (ex. marriage)? br / then you overload the + operator and define what is to be done when you add the objects. br / b
H3How to Overload the operators: ++(int), (int)++, (int), (int) /H3PThe key is to know the action of these operators on the integers they are supplied for: br / br /For coding examples i will again be using Person as my example class. Perhaps ++ or increments or decrements the numbe
H3How to Overload the operators: +=, =, *=, /=, %=/H3PVery similar to overloading the +, ,* operators within a class, as they all take a single parameter as such: br / br /As with all the other Person will be the custom class. br /Perhaps these operations combine the friends of 2 people
H3The name and type of the registers and segments usable by a 32 bit processor (Easily converted by a naming convention to 16 bit and even 64 bit)/H3PSince there are no other recipes on Assembly Language, it would be irrational to start anywhere but the basics of hardware in assembly programmi
H3The EFlags register, what they, what they do and when they are set./H3PThe flags are located in a single 32 bit register (EFlags), each a single bit, thus holding a value of 1 true, or 0 false. br / br /I will list the flags by name, location in the register and use: br /*location will
