Many programmers have learned C ++ and concluded that C ++ is an independent language rather than a C language, you can directly learn C ++ without starting with C. I hope you can learn what you want here.
The "C" language series is the best example of the development of object-oriented design. C ++ provides developers with excellent object-oriented programming tools. programmers can explicitly create constructors, copy constructors, overload operators, and Use templates.
The main problem with complex languages such as C ++ is that it takes several months for programmers to master the nature of object-oriented design. New programmers must learn how to master templates, function overloading, and, of course, create and use classes with good functions.
Microsoft has given C # (read as C-Sharp) Some object-oriented nature to C ++.
- About the formatting of floating point numbers in C ++
- Introduction to C/C ++
- Build a Carbide C ++ Development Platform
- How to better learn C ++
- Introduction to Visual C ++ 6.0 Compiler Learning
For example, the template, but changed the class creation method. In this article, I will compare the C ++ classes and focus on the changes in class creation and usage of Microsoft in C. The object of this article is a skilled C ++ programmer who explains the essence of C # object-oriented through some details.
As you know, C # is partly based on C ++ and partly based on Java syntax. In C #, there are some changes in details so that they can be used in modern design. When you start to use C # To create a class, you will immediately see this. Let's use a simple example to learn how to create and instantiate classes in C ++ and C.
- # Include
- Class MyClass
- {
- Public: void doSomething ()
- {Std: cout<<"This is some text ";
- }
- };
- Void main ()
- {MyClass mc;
- Mc. doSomething ();
- }
-
- C # version:
- Using System;
-
- Class MyClass
- {
- Public void doSomething ()
- {
- Console. WriteLine ("This is some text ");
- }
- }
- Class EntryPoint
- {Public static void Main ()
- {MyClassMc=NewMyClass ();
- Mc. doSomething ();
- }
- }
First, C ++ uses the # include statement to specify the physical path containing the file iostream. h. C # Tells the compiler program to operate in the System namespace. All namespaces and classes belong to the System namespace. C # Use The namespace name to determine the scope of the application (in this example, there is only one namespace in the System), without specifying the File Inclusion Method in the physical path.
Second, the Main program of C # uses Main (note that M is capitalized ). Third, the class declaration of c ++ should end with a semicolon after the ending braces. C # is usable, and is often omitted. Fourth, you can see that the scope of methods and members must be explicitly declared in C. If no declaration is added, the default value is private (only class members can access it), which is the same as that of C ++. C # has five scopes:
Public: other class members can also access
Private: Only class members can access
Protection: Class Members and inherited class members can access
Internal (internal): Only Members in the Assembly can access (C # assembly is a combination of code and resource data, with asmx as the file suffix)