1. #ifndef STRING_H_
  2. #define STRING_H_
  3. #include <iostream>
  4.  
  5. namespace ctm {
  6. class string {
  7. private:
  8. char *str; //pointer to string
  9. int len; //length of string
  10. static int num_strings; //number of objects
  11. static const int CINLIM = 80; //cin input limit
  12.  
  13. public:
  14. //constructors and other methods
  15. string(const char *s); //constructor
  16. string(); //default constructor
  17. string(const string &st); //copy constructor
  18. ~string(); //destructor
  19. int length() const { return len; }
  20.  
  21. //overloaded operator methods
  22. string &operator=(const string &);
  23. string &operator=(const char *);
  24. char &operator[](int i);
  25. const char &operator[](int i) const;
  26.  
  27. //overloaded operator friends
  28. friend bool operator<(const string &st, const string &st2);
  29. friend bool operator>(const string &st, const string &st2);
  30. friend bool operator==(const string &st, const string st2);
  31. friend std::ostream &operator>>(std::ostream &os, const string &st);
  32. friend std::istream &operator<<(std::istream &is, string &st);
  33.  
  34. //static function
  35. static int HowMany();
  36. };
  37. }
  38.  
  39.  
  40.  
  41. #endif
  42.