上一页 1 2 3 4 5 6 7 ··· 23 下一页
摘要: Consider: class B { public: void mf(); // ... }; class D : public B { /*...*/ }; D x; // x is an object of type D B *pB = &x; // get pointer to x pB-> 阅读全文
posted @ 2021-09-28 20:49 MyCPlusPlus 阅读(28) 评论(0) 推荐(0) 编辑
摘要: The Template Method Pattern via the Non-Virtual Interface Idiom: class GameCharacter { public: int healthValue() const // derived classes do not redef 阅读全文
posted @ 2021-09-28 20:34 MyCPlusPlus 阅读(100) 评论(0) 推荐(0) 编辑
摘要: The seemingly straightforward notion of (public) inheritance turns out, upon closer examination, to be composed of two separable parts: inheritance of 阅读全文
posted @ 2021-09-28 11:35 MyCPlusPlus 阅读(36) 评论(0) 推荐(0) 编辑
摘要: C++'s name-hiding rules do just that: hide names. Whether the names correspond to the same or different types is immaterial. int x; // global variable 阅读全文
posted @ 2021-09-14 10:38 MyCPlusPlus 阅读(93) 评论(0) 推荐(0) 编辑
摘要: Consider this code: class Rectangle { public: virtual void setHeight(int newHeight); virtual void setWidth(int newWidth); virtual int height() const; 阅读全文
posted @ 2021-09-13 10:50 MyCPlusPlus 阅读(38) 评论(0) 推荐(0) 编辑
摘要: C++ doesn't do a very good job of separating interfaces from implementations. A class definition specifies not only a class interface but also a fair 阅读全文
posted @ 2021-09-10 18:09 MyCPlusPlus 阅读(81) 评论(0) 推荐(0) 编辑
摘要: When you inline a function, you may enable compilers to perform context-specific optimizations on the body of the function. Most compilers never perfo 阅读全文
posted @ 2021-09-10 14:32 MyCPlusPlus 阅读(77) 评论(0) 推荐(0) 编辑
摘要: Suppose we have a class for representing GUI menus with background images. The class is designed to be used in a threaded environment, so it has a mut 阅读全文
posted @ 2021-09-10 11:12 MyCPlusPlus 阅读(63) 评论(0) 推荐(0) 编辑
摘要: Suppose you’re working on an application involving rectangles. Each rectangle can be represented by its upper left corner and its lower right corner. 阅读全文
posted @ 2021-09-09 19:57 MyCPlusPlus 阅读(44) 评论(0) 推荐(0) 编辑
摘要: Let’s begin with a review of casting syntax, because there are usually three different ways to write the same cast. C-style casts look like this: (T) 阅读全文
posted @ 2021-09-09 18:00 MyCPlusPlus 阅读(43) 评论(0) 推荐(0) 编辑
上一页 1 2 3 4 5 6 7 ··· 23 下一页