// ========================================================================== // Declaration for a string array with random selection // A. Fischer, May 13, 2001 file: rstrings.hpp // ========================================================================== #pragma once #include "tools.hpp" #include "ssstore.hpp" class RandString { protected: const char** data; // Vocabulary array StringStore store; // Storage behind string array. int n; // Number of strings in array. int maxData; private: inline const char* remove( int r ); void print( ostream& outs ) const; // For debugging, make this public. public: RandString( istream& vocin, int sz = 100 ); ~RandString(); void put( const char* word, int len ); const char* randword(); }; //--------------------------------------------------------------------------- inline const char* RandString::remove( int r ) { const char* ret = data[r]; // Grab the word that was selected. data[r] = data[--n]; // Replace by last word in array. data[n] = ret; return ret; // Return word and decrease word count. }