apstring - #ifndef _APSTRING_H #define _APSTRING_H #...

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: #ifndef _APSTRING_H #define _APSTRING_H # #include <iostream.h> // uncomment line below if bool not built-in type // #include "bool.h" / // ******************************************************************* // Last Revised: 11/24/98 - corrected specification comments, dhj // // 8/14/98 corrected comments, dhj // 6/29/98 - commented out the #include "bool.h", dhj // // APCS string class // // string class consistent with a subset of the standard C++ string class // as defined in the draft ANSI standard // ******************************************************************* / extern const int npos; // used to indicate not a position in the string e class apstring { public: // constructors/destructor apstring( ); // construct empty string "" apstring( const char * s ); // construct from string literal apstring( const apstring & str ); // copy constructor ~apstring( ); // destructor // assignment const apstring & operator = ( const apstring & str ); // assign str const apstring & operator = ( const char * s ); // assign s const apstring & operator = ( char ch ); // assign ch // accessors int length( ) const; // number of chars int find( const apstring & str ) const; // index of first occurrence of str int find( char ch ) const; // index of first occurrence of ch apstring substr( int pos, int len ) const; // substring of len chars // starting at pos const char * c_str( ) const; // explicit conversion to char * // indexing char operator[ ]( int k ) const; // range-checked indexing char & operator[ ]( int k ); // range-checked indexing // modifiers const apstring & operator += ( const apstring & str );// append str const apstring & operator += ( char ch ); // append char private: int myLength; // length of string (# of characters) int myCapacity; // capacity of string char * myCstring; // storage for characters }; } // The following free (non-member) functions operate on strings...
View Full Document

Page1 / 4

apstring - #ifndef _APSTRING_H #define _APSTRING_H #...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online