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

📄 nesting.cpp

📁 含有文章和源码
💻 CPP
字号:
                                       // Chapter 6 - Program 7
#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;}
};


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";
}




// 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 + -