|
-
December 28th, 2009, 04:45 AM
#1
Casting variables
I'm learning about casting variables, but something has come up very odd and I can't figure it out!
Please examine this piece of code and explain to me why my result comes out as 65.
Code:
int num = 7;
char letter = 'A';
num = static_cast <int> (letter);
cout<<"Cast character int: " << num << endl;
When printed out, num is equal to 65 however I see no mathematical equation that could have changed num's value unless it has to do with the casting. Please explain this for me, I can't figure it out no matter how hard I think.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|