>Can anyone out there help me write the "Main" part.
#include <iostream>
#include <queue>
using namespace std;
int main()
{
queue<char> q;
char ch;
bool match = true;
cout<<"Enter a message: ";
while ( cin.get ( ch ) && ch != '\n' )
q.push ( ch );
cout<<"Enter another message: ";
while ( cin.get ( ch ) && ch != '\n' ) {
if ( q.empty() || q.front() != ch )
match = false;
q.pop();
}
if ( match )
cout<<"The two messages match"<<endl;
else
cout<<"The two messages do not match"<<endl;
}
Replace the standard queue adaptor with your queue and that's it!
Narue
Bad Cop
15,460 posts since Sep 2004
Reputation Points: 6,464
Solved Threads: 1,401
>What do you mean replace the standard queue adaptor with my queue?
push and pop are equivalent to enqueue and dequeue. Any other changes to use your queue instead of the standard C++ queue are painfully obvious if you give it a shot. Play around with the code and you'll figure it out. What more did you expect me to do? I gave you the answer.
Narue
Bad Cop
15,460 posts since Sep 2004
Reputation Points: 6,464
Solved Threads: 1,401