Jump to content
  • Advertisement

Archived

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

infinitycool

C++ typecasting

This topic is 6019 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

Hi has anyone seen this error before? error C2243: ''type cast'' : conversion from ''class Camera *'' to ''class BaseObject *'' exists, but is inaccessible I''m not sure what the inaccessible part means. Camera is derived from BaseObject so this should work... Thanks for any help beforehand, Infinitycool

Share this post


Link to post
Share on other sites
Advertisement
How have you inherited? If you have private or protected inheritance then you will get this error when you cast back to the base class. ie...


  
class BaseObject {};
class Camera : private BaseObject {};

Camera m_Camera;
BaseObject *m_BaseObject = &m_Camera;

Share this post


Link to post
Share on other sites
Make sure you Camera class is declared like this:

class Camera: public BaseObject {}

If you don''t have the public it defaults to private (or is it protected? I don''t remember...) and you''ll get this error.


codeka.com - Just click it.

Share this post


Link to post
Share on other sites
quote:
Original post by Dean Harding
If you don''t have the public it defaults to private (or is it protected? I don''t remember...) and you''ll get this error.


You are correct. Everything about classes are private as default. Everything about structs are public as default.

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.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!