#include // for exit #include // for isalpha #include // for ifstream #include "ladder.h" #include "queue.h" Ladder::Ladder() : myWords(INITIAL_SIZE), myWordCount(0) // postcondition: fields initialized { } Ladder::~Ladder() { // need to do work here!!! must delete all nodes allocated // in constructor --- students MUST IMPLEMENT THIS FUNCTION!! // (and remove cout statement below) cout << "Warning!! Ladder destructor NOT implemented" << endl; } void Ladder::LoadWords(const string & filename) // postcondition: all words in file 'filename' read and stored // in myWords, # of words = myWordCount { ifstream input(filename); string word; if (input.fail()) { cout << "couldn't open data file " << filename << endl; exit(1); } while (getline(input,word)) // read one line { word = word.substr(0,WORD_SIZE); // truncate # letters if (isalpha(word[0])) // begins with alphabetic char? { if (myWordCount >= myWords.Length()) // double vector if needed { myWords.SetSize(myWords.Length() * 2); } myWords[myWordCount] = new Wnode(word); myWordCount++; } } } void Ladder::Clear() // postcondition: all prev fields == 0 { } bool Ladder::FindLadder(const string & first, const string & last) { } void Ladder::PrintLadder() { }