danielsbrewer
February 25th, 2003, 08:35 AM
Hi there I am trying to construct a composite class of a number of componets called Model.
One of the componets is an abstract class called Equations. An example of one of its member classes (Lorenz) copy member function is:
Equations* Lorenz::copy() const
{
return (new Lorenz(*this));
}
The simplified constructor for class Model is:
Model::Model(const Equations & equat)
:myEquation(equat.copy())
{
}
In main I make an Equations object and then an Model object i.e.
Lorenz button();
Model jelly(button);
Now the problem I have is that if I manipulate the data members of Equations from main, the Equations object in the Model object is not changed.
I checked the memory of the two Equations objects and they are different. Is there anyway to pass the actual object without changing its memory address?
Thanks
One of the componets is an abstract class called Equations. An example of one of its member classes (Lorenz) copy member function is:
Equations* Lorenz::copy() const
{
return (new Lorenz(*this));
}
The simplified constructor for class Model is:
Model::Model(const Equations & equat)
:myEquation(equat.copy())
{
}
In main I make an Equations object and then an Model object i.e.
Lorenz button();
Model jelly(button);
Now the problem I have is that if I manipulate the data members of Equations from main, the Equations object in the Model object is not changed.
I checked the memory of the two Equations objects and they are different. Is there anyway to pass the actual object without changing its memory address?
Thanks