这是effective c++学习笔记,参考自网上翻译:
Introduction
Terminology
- declaration & definition
- declaration: tells compilers about the name and type of something, but omits certain details
extern int x; // object declaration std::size_t numDigits(int number); // function declaration class Widget; // calss declaration template<typename T> // template declaration class GraphNode;
-
definition: provides compilers with the details a declaration omits.
For an object, the definition is where compilers set aside memory for the object.
For a function or a function template, the definition provides the code body.
For a class or a class template, the definition lists the members of the class or template.
int x; // object definition std::size_t numDigits(int number) { // function definition std::size_t digit = 10; return digit * digit; } class Widget { // class definition public: Widget(); ~Widget(); }; template<typename T> // template definition class GraphNode { public: GraphNode(); ~GraphNode(); }
- declaration: tells compilers about the name and type of something, but omits certain details
近期评论