希望我提供的代码对大家有帮助

源代码在线查看: class.cpp

软件大小: 419 K
上传用户: sky8997991
关键词: 代码
下载地址: 免注册下载 普通下载 VIP

相关代码

				//: C05:Class.cpp

				// From Thinking in C++, 2nd Edition

				// Available at http://www.BruceEckel.com

				// (c) Bruce Eckel 1999

				// Copyright notice in Copyright.txt

				// Similarity of struct and class

				

				struct A {

				private:

				  int i, j, k;

				public:

				  int f();

				  void g();

				};

				

				int A::f() { 

				  return i + j + k; 

				}

				

				void A::g() { 

				  i = j = k = 0; 

				}

				

				// Identical results are produced with:

				

				class B {

				  int i, j, k;

				public:

				  int f();

				  void g();

				};

				

				int B::f() { 

				  return i + j + k; 

				}

				

				void B::g() { 

				  i = j = k = 0; 

				} 

				

				int main() {

				  A a;

				  B b;

				  a.f(); a.g();

				  b.f(); b.g();

				} ///:~

							

相关资源