445,804 Members | 1,627 Online
Need help? Post your question and get tips & solutions from a community of 445,804 IT Pros & Developers. It's quick & easy.

# REQ: Help With List Class - Linked List Based

 P: n/a below is what I have for my list class implementation - array based exercise from my book; it works and all. what I was wondering is if someone could help me out and code a 'link list based' solution to this problem. (adding two numbers and outputing the sum). thanks very much. ____________________________________ #include void reportResults(int, int); class CharacterPair { public: int numberOfQuestionMarks() { return ((ch1 == '?'?1:0) + (ch2 == '?'?1:0) ); } bool pairMatch() { return ( ch1 == ch2 || numberOfQuestionMarks() > 0); } bool sentinelPair() { return (ch1 == '*');} void getPair() {cin >> ch1 >> ch2; } private: char ch1; char ch2; }; int main () { CharacterPair cp; int qmCnt = 0, mpCnt = 0; cp.getPair(); while ( !cp.sentinelPair() ) { qmCnt += cp.numberOfQuestionMarks(); if ( cp.pairMatch() ) mpCnt++; cp.getPair(); } reportResults(qmCnt, mpCnt); return 0; } void reportResults (int qCnt, int mCnt) { cout << "Number of Question Marks is: " << qCnt << endl; cout << "Number of Matched Pairs is: " << mCnt << endl; } /* int CharacterPair::numberOfQuestionMarks() { int temp = 0; if (ch1 == '?') temp++; if (ch2 == '?') temp++; return temp; } bool CharacterPair::pairMatch() { return ( ch1 == ch2 || numberOfQuestionMarks() > 0); } bool CharacterPair::sentinelPair() { return (ch1 == '*'); } void CharacterPair::getPair() { cin >> ch1 >> ch2; } */ ____________________________________ Jul 22 '05 #1