I just started learning about stl.... the problem is that 3 cases that i consider "equivelant", don't do the same thing...so the question is, why they are not equivalent?
here are the statements:
cout<<(char)toupper(*pos)<<" "; //this works!
cout<<toupper(*pos)<<" "; //without cast it doesn't work, why?
*pos=toupper(*pos); //and this also doesn't work
cout<<*pos<<" ";
here is the full code::
#include <iostream>
#include <list>
using namespace std;
int main()
{
list<char> coll; //this is the container
for(char c='a'; c<='z'; ++c)
coll.push_back(c);
list<char>::iterator pos;
for(pos=coll.begin(); pos!=coll.end(); ++ipos)
{
cout<<(char)toupper(*pos)<<" "; //this works!
//cout<<toupper(*pos)<<" "; //without cast it doesn't work, why?
//*pos=toupper(*pos); //and this also doesn't work
//cout<<*pos<<" ";
}
cout<<endl;
cout<<'A'-0<<endl;
}