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

📄 pr1306.cpp

📁 practice c++, it is from the book http://www.amazon.com/Schaums-Outline-Programming-John-Hubbard
💻 CPP
字号:
//  Programming with C++, Second Edition, by John R. Hubbard
//  Copyright McGraw-Hill 2000
//  Problem 13.6, page 319
//  An Array subclass template

#include <iostream>
#include "Vector.h"
using namespace std;

template<class T, class E>
class Array : public Vector<T>
{
public:
  Array(E last) : Vector<T>(unsigned(last) + 1) { }
  Array(const Array<T,E>&a) : Vector<T>(a) { }
  T& operator[](E index) const
  {
    return Vector<T>::operator[](unsigned(index));
  }
};

enum Days { SUN, MON, TUE, WED, THU, FRI, SAT };

int main()
{
  Array<int, Days> customers(SAT);
  customers[MON] = 27;
  customers[TUE] = 23;
  customers[WED] = 20;
  customers[THU] = 23;  
  customers[FRI] = 36;
  customers[SAT] = customers[SUN] = 0;
  for (Days day = SUN; day ,+ SAT; day++)
    cout << customers[day] << "  ";
}

⌨️ 快捷键说明

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