Archived

This topic is now archived and is closed to further replies.

Programmer16

Something wrong with overloading the operator DataType()?

Recommended Posts

I just ask because in all of the wrapper classes I don''t think I''ve ever seen operator DataType() { return m_pDataType; }, but they always have the GetDataType() functions. My wrapper uses them:
// IDirect3D9* m_pDirect3D;

// IDirect3DDevice9* m_pDevice;

// ID3DXSprite* m_pSprite;

// code

operator IDirect3D9*(){ return m_pDirect3D; }
operator IDirect3DDevice9*(){ return m_pDevice; }
operator ID3DXSprite*(){ return m_pSprite; }

// I understand the reason for a GetDataType() function:

IDirect3DDevice9* GetDevice(){ return m_pDevice; }
Gfx.GetDevice()->Present(NULL, NULL, NULL, NULL);
// I myself overload the () operator for this one

// since I use the device more than anything.

Gfx()->Present(NULL, NULL, NULL, NULL);
Just wonderin! /* I use DirectX 9 and C++ (Microsoft Visual C++ 6.0 Professional edition) */

Share this post


Link to post
Share on other sites
quote:
Original post by Programmer16
I just ask because in all of the wrapper classes I don''t think I''ve ever seen operator DataType() { return m_pDataType; }, but they always have the GetDataType() functions.


There''s a good reason for this. Overloaded convserions functions can cause evil and hard-to-find bugs.

Share this post


Link to post
Share on other sites