⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 prot_bas.cpp

📁 不错书对C++/C程序员很有用的大家不要错过.
💻 CPP
字号:
#include <iostream.h>

class base 
{
 protected:
   int i, j;
 public:
   void setij(int a, int b) 
   {
     i=a; 
     j=b;
   }
   void showij(void) {cout << i << " " << j << endl;}
 };

class derived : protected base 
{
 private:
   int k;
 public:
   void setk(void) 
   {
     setij(10,12); 
     k = i * j;
   }
   void showall(void) 
   {
     cout << k << " "; 
     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();
 }


⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -