Wouldn't it be much easier to use
std::stack types for the
stack, instead of creating your own stack class ?
Then have two stacks, one where the string is stored reversed, and compare the two, if one item in them don't match, then error out.
And for the toupper()/tolower() thingy you might wanna check
this thread. As you can see there the shift from lowert to upper is actualy a logic or with 32, aswell as when it's to lowere you're using logic and.
Here is a small program for that
Code:
#include <string>
#include <iostream>
int main()
{
std::string text("this iS a TEst");
std::string sResult;
for(unsigned int i = 0; i < text.size(); ++i)
{
if(text[i] >= 'A' && text[i] <= 'Z')
sResult += (text[i] | 32);
else
if(text[i] >= 'a' && text[i] <= 'z')
sResult += (text[i] & (~32));
else
sResult += text[i];
}
std::cout << text << std::endl;
std::cout << sResult << std::endl;
return 0;
}