No. In fact, m_Pods will be an empty vector. As I said, it is local to the function. As soon as control leaves the function, the vector is destroyed. In other words, you do not want to create this local variable at all. Rather, you want to initialise the member variable in the constructor, and destroy it in the destructor.
But in the PodTeam Class there is a function which creates all the pods. In essence it goes through each pod and creates the new function to initiate it. This is done in the PodTeam constructor, and then it is destroyed in the destructor.
I compiled it and it seemed to work, I need to do cout to see if it retains it value. As I have constructed it, the iterator in the PodTeam() class has the createPod() function in the constructor and this places them in the vector:
This is how it is created. Are you saying that it is empty and the pods whose value I am changing in the SpawnPod() function won’t work?
Code:
//------------------------- CreateLevelOnePods ---------------------------------
// this creates the pods for the level
//------------------------------------------------------------------------
void PodTeam::CreateLevelOnePods()
{
//PodBase m_pPodBase; /*->SetAngelPointsBalance(15);*/
//m_pPodBase = new PodBase;
m_Pods.push_back(new PodBase(
1,//int m_iPodESPR,
0,//int m_iLifePath,
1,//int m_iPodIDNumber,
1,//int m_iRegionLocation,
0,//int m_iIslandLocation,
0,//int m_iPierLocation,
1,//int m_iAliveStatus,
1,//int m_iPodProfile,
0
/*WaitPod::Instance())*/));//int m_iPodPointsBalance);
etc with many more similar ones…
What is intended to happen is that the PodTeam’s SpawnPod() function simply iterates this list for the next pod that is unborn so that it can spawn it.
So say if you podA are not born, Once I find you as the (*it) in the ierator of SpawnPod(), I need you to change your setting from unborn to alive. What I need to make sure of is that as long as the pod’s settings are changed inside this function that it is retained after the control leaves the function. The bottom line is that the information of the PodA settings must be preserved. This way if this same function iterates five minutes later this podA can’t be instantiated again since it setting should have changed to alive, that is all I aim to do.
This is the constructor and destructor that I have:
Code:
////----------------------------- ctor -------------------------------------
////
////------------------------------------------------------------------------
//
PodTeam::PodTeam()
{
//PodTeam* m_pPodTeam = new PodTeam;
//create the players and goalkeeper
CreateLevelOnePods();
}
////----------------------- dtor -------------------------------------------
////
////------------------------------------------------------------------------
PodTeam::~PodTeam()
{
std::vector<PodBase*>::iterator it = m_Pods.begin();
for (it; it != m_Pods.end(); ++it)
{
delete *it;
}
}
Are you saying the way I have it set up will not work? Should I test with some couts or is this not going to work. This is my first C ++ program. Thank you for your help and guidance.