Jump to content
  • Advertisement
Sign in to follow this  
MrD 588

C++ "cannot access protected member"

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

Hey all, having a little bit of a weird issue with my inheritance. Here's "NodeGeometry.h":
#ifndef I3D_NODEGEOMETRY_H
#define I3D_NODEGEOMETRY_H

#include "Node.h"
#include "Geometry.h"

namespace i3d
{
	class NodeGeometry : public Node
	{
		public:
			NodeGeometry(std::tr1::shared_ptr<Geometry> geom, const NODE_TYPE &type = NODE_GEOMETRY);
			virtual ~NodeGeometry();

		public:
			virtual void render(LPDIRECT3DDEVICE9 d3dDevice9);

		protected:
			D3DXMATRIX m_localTransform;
			D3DXMATRIX m_worldTransform;

		protected:
			std::tr1::shared_ptr<Geometry> m_geom;
	};
}

#endif
And here is "NodeTADynamic.h" which derrives from "NodeGeometry":
#ifndef I3D_NODETADYNAMIC_H
#define I3D_NODETADYNAMIC_H

#include "Global.h"
#include "NodeGeometry.h"
#include "TA/Physics/Physics.h"
#include "TA/Physics/DynamicObject.h"

namespace i3d
{
	class NodeTADynamic : public NodeGeometry
	{
		public:
			NodeTADynamic(std::tr1::shared_ptr<Geometry> geom, const NODE_TYPE &type = NODE_TADYNAMIC);
			virtual ~NodeTADynamic();

		public:
			TA::DynamicObject* getDynamicObject() { return m_dynamicObject; }

		public:
			virtual void shutdown();

		public:
			virtual void render(LPDIRECT3DDEVICE9 d3dDevice9);

		protected:
			TA::DynamicObject *m_dynamicObject;
	};
}

#endif
However when I compile the code, I get an error:
1>c:\documents and settings\jamie\my documents\svn\terrain\i3d2\i3d2\nodetadynamic.cpp(53) : error C2248: 'i3d::NodeGeometry::m_worldTransform' : cannot access protected member declared in class 'i3d::NodeGeometry'
1>        c:\documents and settings\jamie\my documents\svn\terrain\i3d2\i3d2\nodegeometry.h(20) : see declaration of 'i3d::NodeGeometry::m_worldTransform'
1>        c:\documents and settings\jamie\my documents\svn\terrain\i3d2\i3d2\nodegeometry.h(9) : see declaration of 'i3d::NodeGeometry'
But I don't understand why since it's a protected member and the class is being publicly inherited. Any suggestions?

Share this post


Link to post
Share on other sites
Advertisement
It looks like you're trying to access the variable from a free function rather than a member of NodeTADynamic. Post the relevant section of nodetadynamic.cpp. Also, is that the full list of errors? Syntax problems can sometimes cause spurious errors like that.

Share this post


Link to post
Share on other sites
Nevermind, I was being an idiot. I was trying to access the member through an instance I was creating inside the function.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • 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!