Skip to main content
GameDev.net gamedev.net
🔒 Locked

D3DXVECTOR3 TO bool

Started by luasitdown Jan 21, 2006 at 2:17 AM 5 replies 500+ views
Original Post
luasitdown
luasitdown
void foo(D3DXVECTOR v) { } foo(false); // this pass compiler and work. why??
erissian
erissian
Guessing, I would say that D3DXVECTOR is a pointer. false == 0 == NULL, and NULL is a valid pointer address.
We''re sorry, but you don''t have the clearance to read this post. Please exit your browser at this time. (Code 23)
jollyjeffers
jollyjeffers
Quote:
Original post by erissian
Guessing, I would say that D3DXVECTOR is a pointer.

D3DXVECTOR3 if you're using C is just a regular struct, and under C++ D3DXVECTOR3 is a class.

Jack
<hr align="left" width="25%" />
Jack Hoxley <small>[</small><small> Forum FAQ | Revised FAQ |
luasitdown
luasitdown
Quote:
Original post by luasitdown
void foo(D3DXVECTOR v)
{
}

foo(false); // this pass compiler and work. why??


I make a mistake.

question is :

void far(bool b)
{
}

far(D3DXVECTOR3(0,0,0));
It work . why?
SiCrane
SiCrane
D3DXVECTOR3 has an implicit conversion operator operator FLOAT *(). FLOAT * has an implicit conversion to bool based on whether or not it is null.
luasitdown
luasitdown
Quote:
Original post by SiCrane
D3DXVECTOR3 has an implicit conversion operator operator FLOAT *(). FLOAT * has an implicit conversion to bool based on whether or not it is null.


How to forbid the default cast? it make something under unkonwn, it easy to make bug.
SiCrane
SiCrane
You can hack the headers to remove the implicit conversion or you can use a D3DVECTOR3, which lacks the C++ member functions.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.