Hi All,
I'm fairly new to C++ and have mainly been learning from a couple of books, but I'm working on a complicated (for me) project for a masters, and wondered if anyone could help me with the following:
I have a class StructPlant, which then creates using 'new' two objects of a different class 'StructRoot' and 'StructShoot' inside the constructor.
StructPlant::StructPlant(int n, int m)
{
root_system = new StructRoot(n,m);
shoot_system = new StructShoot(n,m);
}
where root_system and shoot_system are pointers of type StructRoot and StructShoot respectively.
What I need is to have a pointer (presumably) which I can access inside StructRoot or StructShoot which points to the Plant which it is associated with.
Thanks Bazzy, that seems to have worked. I put ptr_to_plant = this; into the Plant constructor, and then PPlant = ptr_to_plant into the Root constructor and I think it's working.