C++Guide.txt 1.6 KB

12345678910111213141516171819202122232425262728293031
  1. A general C++ debugging guide for anyone who might need it.
  2. Cannot find method in namespace:
  3. * Check that the header is included from where it is called.
  4. * Check that the correct namespace is being used.
  5. * Check input arguments.
  6. Having the wrong input is like using another method name because of overloading.
  7. Linker error:
  8. * Check that the cpp file is compiled by looking at the cpp files being mentioned in the terminal.
  9. If not compiled:
  10. * Check that the file's name doesn't contain spaces by mistake.
  11. * Check that it's in a folder being compiled.
  12. * Check that the definition in the cpp file has the identifier declared explicitly in the namespace.
  13. flags returnType namespace::methodName( ... ) flags { ... }
  14. Multiple definitions of method in header:
  15. * Move to cpp implementation which is only compiled once or declare as inline.
  16. Cannot move variable to base class without getting weird behaviour:
  17. * Did the construction of the variable in the list depend on a variable given to the class that it moved to?
  18. Calling a base constructor will not set any of the variables before all of them are complete.
  19. Calls to a class crashes when done from another source file.
  20. * Make sure that each method is implemented in the corresponding source file.
  21. A class fully defined in the header may have contradicting implementations between the sources that include the header.
  22. General rules:
  23. * If a class isn't supposed to be instanciated, make it abstract by letting at least one virtual method be pure.
  24. This reveals if any polymorph argument is passed as a template type to overloading, which ignores the child type and its v-table.