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

📄 nesting.cpp

📁 Since the field of object oriented programming is probably new to you, you will find that there is a
💻 CPP
字号:
                               // Chapter 6 - Program 7 - NESTING.CPP
#include <iostream.h>

class mail_info 
{
   int shipper;
   int postage;
public:
   void set(int in_class, int in_postage)
           {shipper = in_class; postage = in_postage; }
   int get_postage(void) {return postage;}
};

class box {
   int length;
   int width;
   mail_info label;
public:
   void set(int l, int w, int s, int p) {
         length = l; 
         width = w;
         label.set(s, p); }
   int get_area(void) {return length * width;}
};


int main()
{
box small, medium, large;

   small.set(2, 4, 1, 35);
   medium.set(5, 6, 2, 72);
   large.set(8, 10, 4, 98);

   cout << "The area is " << small.get_area() << "\n";
   cout << "The area is " << medium.get_area() << "\n";
   cout << "The area is " << large.get_area() << "\n";

   return 0;
}




// Result of Execution
//
// The area is 8
// The area is 30
// The area is 80

⌨️ 快捷键说明

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