C++ typecasting
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
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;
Make sure you
If you don''t have the
codeka.com - Just click it.
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.
Sorry all. After pasting the code I realized I neglected to declare the base class public. Thanks for the help!
quote:Original post by Dean Harding
If you don''t have thepublic
it defaults toprivate
(or is itprotected
? 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.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement