m_iWidth = (int)pBitmapInf o->bmiHeader.biWi dth;
m_iHeight = (int)pBitmapInf o->bmiHeader.biHe ight;
>
What does this mean?
>
I have seen v=&var->member.thing ;
>
but what does it mean when you change the & for int?
You don't change anythign for anything. The unary operator & is
for taking the address of the operand. The (blah) notation is
for *casting* the left operand into a different type. Look it up
in your favourite C++ book (BTW, which one are you reading that
doesn't describe those?)
V
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask
>
m_iWidth = (int)pBitmapInf o->bmiHeader.biWi dth;
m_iHeight = (int)pBitmapInf o->bmiHeader.biHe ight;
>
What does this mean?
>
I have seen v=&var->member.thing ;
>
but what does it mean when you change the & for int?
v=&var->member.thing ; means that v is going to get the address of
var->member.thing .
&'s precedence is lower than both -and .
Think of it as:
v = &(var->member.thing )
v must be a pointer to whatever type var->member.thing is.
The change you are asking about wouldn't be all, because the type of v
would have to change too.
If this compiles:
int *v = &var->member.thing ;
this of course won't:
int *v = (int)var->member.thing ;
but this will:
int v = (int)var->member.thing ;
"JoeC" <enki034@yahoo. comwrote in message
news:1190080632 .256341.38700@n 39g2000hsh.goog legroups.com...
>
m_iWidth = (int)pBitmapInf o->bmiHeader.biWi dth;
m_iHeight = (int)pBitmapInf o->bmiHeader.biHe ight;
>
What does this mean?
>
I have seen v=&var->member.thing ;
>
but what does it mean when you change the & for int?
To restate what Victor said,
(int) is a "c style cast". In C++ we could use that or the safer, prefered
static_cast<int >.
& is "address of"
* is "contents of" (also called dereferencing).
A cast will convert one type to another. A static cast generally is used to
covert the value of one type to another. Say, for instance, biWidth was a
double. The (int) says to convert it to an integer.
but what does it mean when you change the & for int?
>
To restate what Victor said,
>
(int) is a "c style cast". In C++ we could use that or the safer,
prefered
static_cast<int >.
& is "address of"
* is "contents of" (also called dereferencing).
>
A cast will convert one type to another. A static cast generally is used
to
covert the value of one type to another. Say, for instance, biWidth was a
double. The (int) says to convert it to an integer.
>
Also:
// C style cast
m_iWidth = (int) pBitmapInfo->bmiHeader.biWi dth;
// C++ style (conversion. watch your compile 'warnings'.)
m_iWidth = int( pBitmapInfo->bmiHeader.biWi dth );
but what does it mean when you change the & for int?
>
You don't change anythign for anything. The unary operator & is
for taking the address of the operand. The (blah) notation is
for *casting* the left operand into a different type. Look it up
in your favourite C++ book (BTW, which one are you reading that
doesn't describe those?)
>
What I mean is that where the (int) is there is a&. That is I can get
data from a pointer but what does the (int) or the type in () mean?
V
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask
but what does it mean when you change the & for int?
>
v=&var->member.thing ; means that v is going to get the address of
var->member.thing .
>
&'s precedence is lower than both -and .
Think of it as:
v = &(var->member.thing )
>
v must be a pointer to whatever type var->member.thing is.
>
The change you are asking about wouldn't be all, because the type of v
would have to change too.
>
If this compiles:
int *v = &var->member.thing ;
this of course won't:
int *v = (int)var->member.thing ;
but this will:
int v = (int)var->member.thing ;
>
but what does it mean when you change the & for int?
You don't change anythign for anything. The unary operator & is
for taking the address of the operand. The (blah) notation is
for *casting* the left operand into a different type. Look it up
in your favourite C++ book (BTW, which one are you reading that
doesn't describe those?)
What I mean is that where the (int) is there is a&. That is I can get
data from a pointer but what does the (int) or the type in () mean?
>
It's a 'cast'. Remove it and re-compile. Does the compiler complain?
Comment