A inherited class that inherit a class which already inherit a class already?

Hi I was wondering why I can't acess the absolute base class in this class which inherit a class that inherit the base class?

Example

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
Class obj1
{
    Public:
    int test;
}
Class obj2 : public obj1
{
  //Stuff here

}
Class obj3 : public obj2
{

  //Stuff here
}
obj3 test2;
test2.test 
Last edited on
First you need to create the object.
obj3 test;
Then you can access its members
test.test;
You can.

What error does it give you if you try to access it?
it's class and public, not Class and Public

and there is ";" missing in line 5,10,15,17
Last edited on
those was only a quick example >.<

Here's the real one, and maeriden its doesnt give em any error am just unable to access it
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
class Object
{
		struct Transform
		{
			XMMATRIX Position;
			XMVECTOR LocalRotation;
			XMMATRIX Scale;


			XMMATRIX WorldRotation;
			XMMATRIX Test;
		};
		
		public:
		Object(){}
		Transform Transform;

};


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
class Model:public Object
{
struct Vertex	//Overloaded Vertex Structure
		{
			Vertex(){}
			Vertex(float x, float y, float z): Position(x,y,z)
			{
				Color.x = 1.0f;
				Color.y = 1.0f;
				Color.z = 1.0f;
				Color.w = 1.0f;
					
			};
			Vertex(float x, float y, float z, float u, float v):Position(x,y,z),TextureCordinate(u,v)
			{
				
			};
				
			XMFLOAT3 Position;
			XMFLOAT2 TextureCordinate;
			XMFLOAT4 Color;

		};
		public:
		Model(){}

}


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
class Cube:public Model
{
	public:
	Cube();
	ID3D11ShaderResourceView* Texture;
	ID3D11SamplerState* TextureSamplerState;
	








	
};


and I have declared/created the box like

Cube test;


but I still can't access the other public variables in the absolute base class

by doing
test. <---- nothings there except the cube variables
It doesn't compile if you write test.Transform; inside a function? I don't think there should be a problem in this case but you could try using a different name for the variable than the type.
But it works if my test is a model type and not a cube
Anyone else knows why? or another way for me to access the Transform from the cube class?
Transform Transform;
Don't you get an error here? The type is same to the variable. Change it and retry maybe?
No, I dont get a error :(, and tried to change it to test still doesnt work.
Forgot to mention,
All these is in 3 diffrent headers if that matters
Last edited on
Actually I just solved it >.<, Just put all those in the same header and it work.
Sorry for wasting you guys time. and if anyone knows how to get it work in diffrent headers please do tell me :3
Topic archived. No new replies allowed.