Jump to content
  • Advertisement

Archived

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

Programmer16

Something wrong with overloading the operator DataType()?

This topic is 5173 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

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
Advertisement
It''s all a matter of preference and coding style. There are minor differences at the assembly level but nothing important really.

Intro Engine

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
So THIS is why Sun thought that operator overloading is harmful and left it out of java. It''s all YOUR fault!

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!