+ 1
In this code how output is 65?
#include <iostream> using namespace std; int main() { union data { int i; unsigned c; }data; data.i=89; data.c='A'; cout<<data.i; return 0; }
2 Antworten
0
union is memory area, that stores all its members, but it's is size of biggest member. int and unsigned int have same size, so I and c take same memory area and if c changed i changed too.
0
Try change c to 4 000 000 000 and look at I. It should wonder you. But that value depends on your compiler.