#ifndef ZIPCODE_H #define ZIPCODE_H #include //for class ostream #include //for class string using namespace std; template class zipcode { private: string digits; public: zipcode(const string& s) { if (s.size() != N) { cerr << "zipcode<" << N << "> must have N chars, not " << s.size() << ".\n"; exit(EXIT_FAILURE); } if (s.find_first_not_of("0123456789") != string::npos) { //if we found a non-digit cerr << "zipcode<" << N << "> must have only digits.\n"; exit(EXIT_FAILURE); } digits = s; } friend ostream& operator<<(ostream& ost, const zipcode& zip) { return ost << zip.digits; } }; #endif