《C/C++程序员实用大全》配套代码,适用初学C++的人员。

源代码在线查看: prot_bas.cpp

软件大小: 608 K
上传用户: yyyz
关键词: 程序员 代码
下载地址: 免注册下载 普通下载 VIP

相关代码

				#include 
				
				class base 
				{
				 protected:
				   int i, j;
				 public:
				   void setij(int a, int b) 
				   {
				     i=a; 
				     j=b;
				   }
				   void showij(void) {cout 				 };
				
				class derived : protected base 
				{
				 private:
				   int k;
				 public:
				   void setk(void) 
				   {
				     setij(10,12); 
				     k = i * j;
				   }
				   void showall(void) 
				   {
				     cout 				     showij();
				   }
				 };
				
				void main(void)
				 {
				   derived object;
				
				   // object.setij(2,3);   This is an illegal command, because setij is a protected member of derived.
				   // object.showij();      This is also an illegal command.
				
				   object.setk();
				   object.showall();
				 }
				
				
							

相关资源