C + + naming chat

Source: Internet
Author: User

The traps in C + + were so many that they made a mistake a long time ago. I defined the _utility_ in a header file, followed by the vector header file, and the result was an error in the following vector declaration (the display does not allow the use of incomplete types ). This makes me very depressed: I clearly contain the vector header file, but also use using the instructions. After a few simple analyses and attempts, the problem is easily solved. This is a naming conflict issue where we previously defined the _utility_ and vector header files in conflict. A simple question code is attached below:

Utility.h

1 #ifndef _utility_ 2 #define _utility_34#endif

Utility.cpp

1#include"Utility.h"2#include <iostream>3#include <vector>4 5 usingstd::vector;6 usingstd::cout;7 usingStd::endl;8 9 intMain ()Ten { One  Avector<int> Ivec = {1,2,3 }; -     //This will prompt you not to allow the use of incomplete types -      for(auto I:ivec) thecout << i <<Endl; -  -  -System"Pause"); +     return 1; -  +}

Naming is a problem, I feel I now the naming specification is Win32 way + other way, such as: Class name First Capital, function, method list Word capitalization, class members before underlined, there are some common. Microsoft's Hungarian nomenclature some places now seem a bit cumbersome, inum people will be directly named Num. This is the same readability, and the compiler will prompt the type int. Then use pinyin to name the feeling is too unprofessional, so still more recite the word!

C + + naming chat

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.