Thinking in C++, 2nd Edition, Volume 2. 英文doc版 每章源代码

源代码在线查看: protected.cpp

软件大小: 244 K
上传用户: caozijianlovenb
关键词: Thinking Edition Volume 2nd
下载地址: 免注册下载 普通下载 VIP

相关代码

				//: C14:Protected.cpp
				// From Thinking in C++, 2nd Edition
				// Available at http://www.BruceEckel.com
				// (c) Bruce Eckel 2000
				// Copyright notice in Copyright.txt
				// The protected keyword
				#include 
				using namespace std;
				
				class Base {
				  int i;
				protected:
				  int read() const { return i; }
				  void set(int ii) { i = ii; }
				public:
				  Base(int ii = 0) : i(ii) {}
				  int value(int m) const { return m*i; }
				};
				
				class Derived : public Base {
				  int j;
				public:
				  Derived(int jj = 0) : j(jj) {}
				  void change(int x) { set(x); }
				}; 
				
				int main() {
				  Derived d;
				  d.change(10);
				} ///:~
							

相关资源