noinsitu.cpp
来自「Thinking in C++ 2nd edition source code 」· C++ 代码 · 共 44 行
CPP
44 行
//: C09:Noinsitu.cpp
// From Thinking in C++, 2nd Edition
// at http://www.BruceEckel.com
// (c) Bruce Eckel 1999
// Copyright notice in Copyright.txt
// Removing in situ functions
class Rectangle {
int Width, Height;
public:
Rectangle(int W = 0, int H = 0);
int width() const; // Read
void width(int W); // Set
int height() const; // Read
void height(int H); // Set
};
inline Rectangle::Rectangle(int W, int H)
: Width(W), Height(H) {
}
inline int Rectangle::width() const {
return Width;
}
inline void Rectangle::width(int W) {
Width = W;
}
inline int Rectangle::height() const {
return Height;
}
inline void Rectangle::height(int H) {
Height = H;
}
int main() {
Rectangle R(19, 47);
// Transpose width & height:
R.height(R.width());
R.width(R.height());
} ///:~
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?