//letter.cpp #include"letter.h" //even though private, the static data must //be given initial values globally. //It may not be modified this way later. int Letter::lowerToUpper='A'-'a'; Letter::style Letter::theCase=lower; void Letter::setStyle(style s) { theCase=s;} void Letter::setLetter(char x) { if ('A'<=x && x<='Z') c=x-lowerToUpper; else c=x; } char Letter::getLetter() { if ('a'<=c && c<='z') //c is a letter return c + theCase*lowerToUpper; return c; } bool Letter::operator==(Letter right) {return c==right.c;} //Since operator<< and operator>> are not member functions //there is no Letter:: in front. //operator<<, as defined, doesn't need to be a friend. ostream& operator<<(ostream& out, Letter let) { out << let.getLetter(); return out; } istream& operator>>(istream& in, Letter& let) { in >> let.c; if ('A'<=let.c && let.c<='Z') let.c=let.c-let.lowerToUpper; return in; }