- string: #include <string> when using std::string
- header: #include "BaseClass.h" when doing inheritance
- main, header: #include "RelevantClass.h" in main function
- basic IO: #include <iostream> when using cout cin endl
- method: in cpp, ReturnType ClassName::method(int& para){};
- Precedence <<: shall cout<<(string1==string2); rather than cout<<string1==string2;
- new: Class* ptr = new Class; rather than Class* ptr = new Class(); unless you got a constructor with Class(para=default)]
- static: static methods correspond to static attributes
- Overloading "<<":
- inside class: ostream& operator<<(ostream& ostr)
- outside class: ostream& operator<<(ostream& ostr, Class& obj)
- the method itself: return ostr<<string1+string2+string3;
Wednesday, May 22, 2013
Common Errors in C++
Labels:
C++
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment