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 + +)