Wednesday, April 16, 2014

Common C++ Errors

1. Programming errors
 These are generated when typographical errors are made by users.

2. Compiler errors 
These are errors detected by the compiler that make the program un-compilable.

3. Linker error
 These are errors generated when the executable of the program cannot be generated. This may be due to wrong function prototyping, incorrect header files.

4. Execution error
 These errors occur at the time of execution. Looping and arithmetic errors falls
under this category.

5. Logical errors
These errors solely depend on the logical thinking of the programmer and are easy to detect if we follow the line of execution and determine why the program takes that path of execution.



Listed below are some common programming errors
1. Misuse of the Include Guard.
A common mistake is to use same symbol in multiple files for #ifndef.
2. Typo's : Using ">" for ">>" and "<" for "<<"
3. Trying to directly access the private variables in the main program.
4. Switch Statments without break.
5. Wrong usage of postfix and prefix operator (diff between i++ and ++i)
6. Undeclared and Unitialised Variables and functions.
7. ALWAYS USE MAKE FILE if you have more than one C++ program. The order of
compilations matters a lot too.
8. Trying to include "INCORRECT" header fuction.
9. Marking a member function as const in the class definition but not in the member function implementation.
10. Returning a value in a void function.

0 comments:

Post a Comment