Ok, for some reason I have problems with class inheritance …
#1)Im doing some OpenGL work where I will need to access data of structures of 2 different classes… They both have 1 structure each.
My problem is that even with Inheritance, I was unable to access the Parent Structure throgh Child class, even though I declared Structure object under public.
My solution was to get the Address of the Parent Structure, and send it to Child structure, where then I would assign that address to Child structure, and this way I could link them and access its DATA …
My problem for that is , I was successful to get the address accross but ONLY through the MAIN program … You know, I would access Parent function (which returns address) in the Main, and get address, and assigned it to some variable, and then I would call Child class and send this Address to particular function … And it Works… However when I tried to call the Parent Function from the Child function I ALWAYS got 0’s for the Address…
I thought that it doesn’t matter from WHERE I call the Parent’s function… It should always have access to Parent’s variabels, and should return the Address with NO Problem .
Why can’t I get values from Parent Class public member variables, whenever I call Parent Class Function from Child Class functions… However when I call Parent Class Functions from the Main, Everything works …
My basic Declerations are like that :
class Parent
{
public:
int returnADD();
private:
int ADDstorage;
}
class Child : public Parent
{
public:
void assingADD()
private:
int store;
}
void Child:assingADD()
{
store=returnADD() // even tried store=Parent::returnADD();
}
etc …
Oh by the way… GO KINGs !!!