A
Alex Vinokur
Why does one need to use two kinds of sizeof operator:
* sizeof unary-expression,
* sizeof (type-name)
?
Their behavior seem not to be different (see an example below).
------ C++ code ------
#include <iostream>
using namespace std;
int main()
{
int x = 100;
cout << sizeof ++x << endl; // expression sizeof
cout << x << endl;
x = 100;
cout << endl;
cout << sizeof (++x) << endl; // type sizeof
cout << x << endl;
return 0;
}
----------------------
------ Run ------
4
100
4
100
-----------------
Alex Vinokur
email: alex DOT vinokur AT gmail DOT com
http://mathforum.org/library/view/10978.html
http://sourceforge.net/users/alexvn
* sizeof unary-expression,
* sizeof (type-name)
?
Their behavior seem not to be different (see an example below).
------ C++ code ------
#include <iostream>
using namespace std;
int main()
{
int x = 100;
cout << sizeof ++x << endl; // expression sizeof
cout << x << endl;
x = 100;
cout << endl;
cout << sizeof (++x) << endl; // type sizeof
cout << x << endl;
return 0;
}
----------------------
------ Run ------
4
100
4
100
-----------------
Alex Vinokur
email: alex DOT vinokur AT gmail DOT com
http://mathforum.org/library/view/10978.html
http://sourceforge.net/users/alexvn