Where can I start learning C ++?

Source: Internet
Author: User

Many people share the same process of learning the C ++ language as that of learning the VC ++ language. This will lead to many detours, after studying VC ++ for a long time, I have to go back and learn the C ++ language. Let's talk about how C ++ feels.

Although C # does not yet support generic programming, I believe this function will be added in the future.) The template is a complex part of C ++, but as a real C ++ programmer, this part is very important. It is particularly important to master the C ++ standard library.

At the beginning, do not directly rush to various guides and designers in VC. Because a lot of code generated by relying on the development environment will confuse us, it is not conducive to learning the C ++ language itself. My suggestion is to generate an empty console project and add files to it by yourself.

 
 
  1.  //robindy/list.cpp  
  2.  
  3. #include <iostream> 
  4. #include <list> 
  5.  
  6. using namespace std;  
  7.  
  8. int main()  
  9. {  
  10. list<char> coll;  
  11.  
  12. for(char c = \'a\'; c <= \'z\'; ++c)  
  13. {  
  14. coll.push_back(c);  
  15. }  
  16.  
  17. list::const_iterator pos;  
  18. for(pos = coll.begin(); pos != coll.end(); ++pos)  
  19. {  
  20. cout << *pos << \' \';  
  21. }  
  22. cout << endl;  
  23.  
  24. return 0;  

This program uses the standard template library to print characters a ~ on the screen ~ Z. Only two types of main functions are accepted by the C ++ Standards Committee. Only the following two methods are compatible with the C ++ standard and can be transplanted. That is:

 
 
  1. Int main ()
  2. {
  3. }
  4. And
  5. Int main (int argc, char * argv [])
  6. {
  7. }

I do not recommend that beginners start with the template library from the very beginning, but I suggest learning the Template Library gradually. For example, we should be familiar with cout and cin usage in iostream), and reduce the use of printf and scanf in the old C function library.

The advantage of starting from the console is to avoid understanding other code generated by tools such as the wizard in VC, and the entire program process is clear. A major difficulty for beginners to learn about VC is that they cannot figure out the entire program process starting from the statement and then exit from the statement. MFC has made too many encapsulation to cover up the truth.

Through the console, we can quickly learn many new features in the C ++ language. Such as class encapsulation, inheritance, and polymorphism. Through this period of study, we must be able to master three things: C ++ keywords, the focus of the syntax is on object-oriented, and templates) learning how to use C ++ requires a lot of time and effort ). A large part of the interface-related interfaces (MFC) are interface-related classes, so I think it is very bloated and boring! Looking back at the previously written programs using MFC, there is a kind of "junk" feeling .)

Test it by yourself: Write a console program, in which class inheritance, function overload, dynamic polymorphism is implemented through virtual functions), Data encapsulation, and use of c ++ standard library.

If you can do it easily, congratulations! You have learned how to understand C ++. However, C ++ is really a complicated stuff, with a variety of strange syntaxes. If you do not have three or five years of skill, do not say you understand C ++.

  1. Differences between standard input implementation methods in C and C ++
  2. How does the C ++ compiler allocate storage space for Const constants?
  3. Basic Conception and method of C ++ Class Library Design
  4. Several Methods for converting C ++ Language
  5. How to better compile C ++ code

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.