Summary of recent bug lists (C + +)

Source: Internet
Author: User

Recently wrote a large piece of code, the abstract is very strong, easy to go around, because the cost of writing a single test is very large (excuse), so many problems to the joint is not found.

And it took a lot of experience to find out, the main problem has the following questions

1. Variable not initialized

Specifically, it is the pointer and the like, this is more than encountered before, the current is very little, come out to say because this time with a stack on a single case (a common singleton, usually a new object) implementation.

Because the usage is not understood deeply, it causes the object to be initialized.

2. Failed to bind port

After the bind port fails, the main thread exits, and then the threads on the boot are dropped from the core. From the core file analysis of what is the problem with the thread, but then constantly delete the code, the final location is the port binding failed, the other port is good.

If you go to the log early, you don't have to be around this big bend!!

3. Auto-complete

When writing the code, VIM's auto-completion function is used, which causes the function to return 1, the sample code is as follows

int class::init (int output, int input) {    //arg check    if (output_)    {         return-1;    }    .....}

In this case, the compiler has no errors at all, and can only rely on its own caution.

4. Inheriting classes calling the base class function with the same name

The basic instance code is as follows

Class Base {public:   int init (int output, int input);}; Class class:public Base {int init (int output, int input);}; int class::init (int output, int input) {    //arg check    if (output_)    {         return-1;    }         return base::init (output, input)    return init (output, intput);}

The inherited class has the same name as the parameter list called the base class parameter list, originally just want to call the base class init function, but because of override, so still will continue to call Class::init (), will eventually because the recursive stack depth core dropped.

At this point, you need to display the specified call as a base class function.

Summary of recent bug lists (C + +)

Related Article

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.