hi all. i guess i need to brush up on my c++ classes cos this one has me stumped.
my situation is is that i have 3 classes. for simplicity lets call them Class A, B & C.
Class A instaniates Class B which by inheritance instantiates Class C. Therefore Class A has access to all of the public member functions that Class B does. thats not even my problem just laying the groundwork. therefore:
CODE
//in class A.h
#include <B.h>
.....
B *reader;
......
struct myStructA
{
string name;
int id;
};
myStructA *x;
------------------------------
//in class A.cpp
reader = new B();
CODE
//in classB.h
Class B : public Class C
{
};
In Class C i have a struct that i have defined as such:
CODE
struct myStructC
{
string name;
int id;
};
myStructC *x;
eventually i will find out how many of this type i will need and like so:
x = new myStruct[some_number];
then i will proceed to fill up this in memory. easy enough.
Now what i want to do is write a function in this class to return this struct to Class A so Class A can use the contents of the data. this will require Class A to call the public member getData in Class C and this is where the heart of my question/problem lies.
so here is my Class C function to return the struct:
CODE
ClassC::myStructC ClassC::getData()
{ return *x; }
now is this correct or am i missing something here?
if this is correct what do i need to in Class A to make sure it calls this function correctly because right now all i get are compiler errors. i would print them here but i have tried so many different things. so far what i have done in Class A is define the exact same struct so when class A calls the getData function it can receive a copy of the struct that is returned from Class C: so one of the things i have tried so far is:
myStructA = reader->getData(); -- where reader up above is defined. this would be the ideal way it would seem to solve this problem but sadly this isnt compiling.
can anyone help me out here with some code to make this happen? just FYI this isnt homework but its a roadblock to something that i working on, on my own. if you could help i would be eternally grateful

thanks all in advance!