|
|
|
#1 |
|
Messages: n/a
Hébergeur: |
#include <iostream>
#include <string> using namespace std; int main() { char t1; struct t2{ char x; }; cout << sizeof(t1) << " " << sizeof(t2) << endl; typedef char& x1; struct x2{ x1 x; }; cout << sizeof(x1) << " " << sizeof(x2) << endl; } output: 1 1 1 4 Can anybody tell me why the size of x2 is 4? Why it's not 1? |
|
|
|
#2 |
|
Messages: n/a
Hébergeur: |
On Feb 22, 8:58pm, "webinfin...@gmail.com" <webinfin...@gmail.com>
wrote: > #include <iostream> > #include <string> > > using namespace std; > > int main() { > char t1; > struct t2{ > char x; > }; > > cout << sizeof(t1) << " " << sizeof(t2) << endl; > > typedef char& x1; > struct x2{ > x1 x; > }; > > cout << sizeof(x1) << " " << sizeof(x2) << endl; > > } > > output: > 1 1 > 1 4 > > Can anybody tell me why the size of x2 is 4? Why it's not 1? The following article should : http://www.eventhelix.com/RealtimeMa...ndOrdering.htm -- EventStudio 4.0 - http://www.Eventhelix.com/Eventstudio/ Sequence diagram based systems engineering tool |
|
![]() |
| Outils de la discussion | |
|
|