PDA

View Full Version : wanted to re-instantiate two classes from a class



salmanmanekia
22nd August 2008, 08:25
#include "Progress.h"
#include "TrainNavigation.h"
..
TrainingUI::TrainingUI()
{

progress = new Progress(this);
progress->setGeometry(30,250,350,350);

navigate = new TrainNavigation(this);
navigate->setGeometry(30,20,350,200);

}

void TrainingUI::resetTraining()
{
delete progress;
delete navigate;
// here i wanted to reinstate progress and navigate such that that it should be logical and efficient
}

i tried to put the code in the constructor in a static member function and tried to call that function from constructor and resetTraining() ..but it didnt worked..any help...e

jacek
22nd August 2008, 08:43
i tried to put the code in the constructor in a static member function
You can't access member variables in static methods.

spirit
22nd August 2008, 08:59
maybe the easiest way is: create a method in both classes like clear() or init() which will set initial state of an object and refuse from physically deleting of objects?