Dec 13, 2012 at 12:26pm UTC
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 Dec 13, 2012 at 12:27pm UTC
Dec 13, 2012 at 12:28pm UTC
First you need to create the object.
obj3 test;
Then you can access its members
test.test;
Dec 13, 2012 at 1:05pm UTC
You can.
What error does it give you if you try to access it?
Dec 13, 2012 at 1:26pm UTC
it's class and public, not Class and Public
and there is ";" missing in line 5,10,15,17
Last edited on Dec 13, 2012 at 1:28pm UTC
Dec 13, 2012 at 2:12pm UTC
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.
Dec 13, 2012 at 2:17pm UTC
But it works if my test is a model type and not a cube
Dec 15, 2012 at 8:23pm UTC
Anyone else knows why? or another way for me to access the Transform from the cube class?
Dec 15, 2012 at 8:45pm UTC
Transform Transform;
Don't you get an error here? The type is same to the variable. Change it and retry maybe?
Dec 15, 2012 at 9:23pm UTC
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 Dec 15, 2012 at 9:32pm UTC
Dec 15, 2012 at 9:34pm UTC
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