Similarity and difference with C/C++
C# is directly related to C and C++. This is not just an idea, this is real. As you recall C is a root for C++ and C++ is a superset of C. C and C++ shares several syntax, library and functionality. In addition structures, unions, arrays, strings and pointers are most important and similar functionality for both languages. C# inherits most of its operators, keywords, and statements directly from C++. Enums are clearly a meaningful concept in C++. Finally I can clearly say that C# is the first component-oriented language in the C/C++ family. C# constructors are very similar with C++ constructors. Like C++, methods are non-virtual by default, but can be marked as virtual. There is also some difference between C# and C++, C# supports multiple inheritance of interfaces, but not of classes. Another difference is destructors, their syntax is same with C++ but actually they are very different.
Most of the C# basic types have the same names as C++ basic types but they are not really same. For example a char in C# is equivalent to a wchar_t in C++. If you decide to move from C++ to C# there are a few things to watch out to include the changes to new, structs, constructors, and destructors. Creating and using a component (DLL) in C# is fairly easier than in C++. One more thing, Borland's C++ Builder was a pure C++ with simple RAD environment of Delphi
2006-06-25 02:55:46
·
answer #1
·
answered by Kerov Rickardo 2
·
1⤊
0⤋
C++
int j = 30;
Myclass *pMine=new Myclass
C#
Int j=30;
Myclass mine=new Myclass()
C++
if(x)
{ … }
C#
If(x != 0)
{ … }
C++
switch (i)
{
case 4:
CallFuncOne();
case 5: // error, no fall through
CallSomeFunc();
}
C#
switch (i)
{
case 4:CallFuncOne();
goto case 5;
case 5:
CallSomeFunc();
}
2006-06-25 09:57:24
·
answer #2
·
answered by Sean I.T ? 7
·
0⤊
0⤋