pghsteelers
Technical User
I understand how "cout" works and can show in a simple statement such as:
char name = 'Tom';
cout << "My name is " << name;
And it will out put "My name is Tom" to the screen.
But can someone explain how the follow statement actually carries the variable through the stream output such as:
#include <iomanip>
char capital = 'A'
cout << hex << static_cast<int>(capital);
You can bypass explaining the static_cast as I know about that, I just like to know the "Why's" something happens to grasp everything about it. And applying the same operation as I see the first example, doesn't show me how the program knows that it is syphoning the variable "capital" through the manipulator "hex".
What am I missing that makes that statement be read differently than the first example and not want to place to variables (hex and capital) as output to the screens?
What if "hex" was changed out with something else like an expression (capital + 'B').
Can anyone clarify how I should be seeing the second example different that the first? or how I shoud read it?
char name = 'Tom';
cout << "My name is " << name;
And it will out put "My name is Tom" to the screen.
But can someone explain how the follow statement actually carries the variable through the stream output such as:
#include <iomanip>
char capital = 'A'
cout << hex << static_cast<int>(capital);
You can bypass explaining the static_cast as I know about that, I just like to know the "Why's" something happens to grasp everything about it. And applying the same operation as I see the first example, doesn't show me how the program knows that it is syphoning the variable "capital" through the manipulator "hex".
What am I missing that makes that statement be read differently than the first example and not want to place to variables (hex and capital) as output to the screens?
What if "hex" was changed out with something else like an expression (capital + 'B').
Can anyone clarify how I should be seeing the second example different that the first? or how I shoud read it?