Concept of C ++ (1)

zhaozj2021-02-16  107

Many people use the C language as a learning VC, I used to walk through such a detour. It is still going back to learn the C language itself after learning for a long time VC.

So where do C start?

The C language introduces two large new things for C language, one is object-oriented (the specific class is class), and the template technology (template programming or generic program is coming in very popular technology, in C # Although there is no support for generic programming, it is believed that this feature will be added in the future), and the template is a complicated part of C , but as a real C programmer, this is important. Especially the mastery of the C standard library is particularly important.

Don't just start the various wizards and designers in the VC when you start. Because many of the code that relies on the development environment will make us confused, it is not conducive to our learning C language itself. My suggestion is to generate an empty console project and then add a file to it.

The following is a simple console program:

//robindy/list.cpp

#include

#include

Using namespace std;

int main ()

{

List Coll;

For (char c = 'a'; c <= 'z'; c)

{

COLL.PUSH_BACK (C);

}

List :: const_iterator pos;

For (POS = Coll.begin (); POS! = COLL.End (); POS)

{

Cout << * pOS << '';

}

Cout << Endl;

Return 0;

}

Interpretation of Using Namespace Std;

The so-called Namespace is a variety of visible ranges of the identifier. All identifiers in the C standard library are defined in a namespace called STD.

Due to the Namespace concept, there can be three options when using any identifier of the C standard library:

1. Specify the identifier directly. For example std :: ostream rather than ostream. The full statement is as follows:

Std :: cout << std :: hex << 3.4 << std :: endl;

2, use the using keyword.

Using std :: cout;

Using std :: end1;

The above program can be written

Cout << std :: hex << 3.4 << endl;

3, the most convenient is to use using namespace std; all identifiers defined in the namespace STD are valid (exposure). It seems that they are declared as global variables. So, the above statement can be written as follows:

Cout << HEX << 3.4 << endl;

This program uses a standard template library, printing characters a ~ z on the screen, where the MAIN function is only accepted by the C Standard Commission, only the following two ways are compliant with C standard, it is Transplantation. which is:

int main ()

{

}

with

Int main (int Argc, char * argv [])

{

}

C defines an implicit RETURN 0 at the end of Main (); however, the Return statement must be explicitly explicit in the VC. You can compile RETURN in the BCB.

The container in STL is used in this program: linked list. First insert 26 letters into the list, then from the traversal chain table, output characters.

I don't recommend that beginners start from the template library at the beginning, but I suggested learning template libraries. If we should be familiar with COUT and CIN usage (located in iostream), reducing Printf and Scanf in the vintage C function library.

The advantage from the console is to avoid other code generated by tools that we understand the VC center, the entire program process is clear. A big difficult problem with the novice learning VC is to engage the process of the entire program (from that statement to execute, then exit from that statement. MFC has made too many packages, covering the truth, ^ _ ^). We can quickly learn a lot of new features in the C language through the console. Such encapsulation, inheritance and polymorphism. Through this period of learning, you must be able to grasp three things: C keywords, syntax (focus is related to object-oriented, and template), C standard library (know how to use it, you must thoroughly need a lot of time and energy ). As for the interface related to the interface (a large part of the MFC is related to the interface, I think the MFC is very bloated and bored! Looking back, I have seen the program written by MFC, there is a "garbage" feel.)

Do your test:

Write a console program that reflects the inheritance of the class, the function is overloaded, dynamic polymorphism (through virtual function implementation), data package, C standard library.

If you can easily get it, congratulations, you have passed the C language. However, C is really a complex stuff, which has a variety of strange syntax, if there is no three, five years of skill, don't say that you know C . ^ _ ^.

Recommended books

"Thinking In C " (if you have energy, you can read the original version directly)

"Essential C "

Originally, I plan to continue to talk about how to enter the C world, but I'm thinking about it, I don't think I will solve a problem first: Why do I want to learn C ? I think it is interested in learning new things in the software development. In addition to the livelihood, learning new things should be guided by interest. So I will open my personal pair of C , I want to build C confidence and interest for you. At the beginning, I learned that I learned C is: I can't waste halfway! At first, it was an interest-driven. Later, it was a livelihood, and finally returned to interest. After all, I have been having fun, this is enough. Solving motive problems before learning a new thing. Just like a murder, if it is just sudden rise, then after trying, it is no sense of accomplishment. The revolutionary martyrs have made a good example for us. Even if we encounter too many confusion and pain on the road to study C , we have made efforts to our beliefs, we know what you are doing, know yourself in pursuit what.

What kind of development is C suitable for?

C is a large language widely used in industrial software development. It has high complexity and ability to solve problems. C is not only a very value in development, but also has a high value in the academic world. Articles about C should be able to describe the voyage of the smoke. C world-class classic books are also countless. However, the development language is so prosperous, even Microsoft has also launched a new development language C #. A undeniable reality is that in the low-order programming field, C squeezed C and also suffering from the strong rebound of C, it is said that it is said to be a Microsoft operating system source code, many of which is a C language. In the high-order programming field, Java and C # are constantly eating C sites. Perhaps Java and C # frenzy will eventually force C to return to this bite - returning to it with fundamental advantages: low-level system program design, high-level high-performance application design, embedded program design, general program design, numerical scientific calculations, etc. . As such, I think this is not a good thing. The high performance and large-scale numerical calculations required by the power system software are being good at C . For Nanrui and Luneng I have contacted, many software involved in power systems such as PAS, etc., are developed with C . Develop this position in the power system software, C is very useful. C attracts such intellectual investment, so that excellent works in this field, including heavyweight software products, libraries, and books, etc. On the Parent Bjarne Stroustrustroup of C , there is some (all or most) systems, applications, and libraries written in C .

Here are some examples (taken from glory websites):

o Adobe Systems: All major applications are developed using C , such as Photoshop & ImageReady, Illustrator, and Acrobat, etc.

O Maya: Does the "Spider Man", "Refers to the Rings King"? What software is used? That's right, it is Maya.

o Amazon.com: Develop large e-commerce software using C .

o Apple: Some important "parts" are written in C .

o AT & T: The largest telecommunications technology provider in the United States, main products are developed in C .

o Google: Web Search Engine is written in C .

o IBM: OS / 400.

o Microsoft: The following products are mainly written in C (Visual C ):

o Windows XP; Windows NT: NT4,2000; Windows 9x: 95,98, Me; Microsoft Office: Word, Excel, Access, PowerPoint, Outlook; Internet Explorer, including Outlook Express, Visual Studio: Visual C , Visual Basic, Visual The FoxPro .NET Framework class library is written in C #, but the C # compiler itself is written using C . Exchange SQL Server FrontPage Project, all games ...

o KDE: K Desktop Environment (Linux). o Symbian OS: One of the most popular cellular phone OS.

转载请注明原文地址:https://www.9cbs.com/read-10272.html

New Post(0)