Why can't I call the vector created in the class file?
#include <vector>
// includes etc removed but class works fine except for vector
class NonPlayerChar
{
public:
NonPlayerChar(string, double, double, double);
~NonPlayerChar(void);
private:
vector<EffectorVector> m_CurrEffectVec;
}
void NonPlayerChar::AddEffector(string type, int time, double str)
{
m_CurrEffectVec.push_back(new EffectorVector(type, time, str) );
};
// called globally in main
vector<NonPlayerChar> myEnemies;
// called within main function
myEnemies[chooseEnemy-1].AddEffector("bleed", 2000, 3.5f);
I don't understand why it won't let me action this code, it doesn't need to be a pointer as I'm not returning the information to the main function.
Getting lost with vector call in class
error C2440: 'initializing' : cannot convert from 'std::_Vector_iterator<_Myvec>' to 'std::_Vector_iterator<_Myvec>'
You defined vector<> to store objects
But try to put pointer in there.
vector<EffectorVector> m_CurrEffectVec;
But try to put pointer in there.
m_CurrEffectVec.push_back(new EffectorVector(type, time, str) );
Okay I'm getting lost again here.
main->callBaddieVector[BaddieClassObject]->CheckParasiteVector[ParasiteClassObject]->m_health
where CheckParasiteVector is generated within the class constructor for the BaddieClassObject.
I thought that vector calls were already created on the heap so I don't need to create a pointer unless I'm calling m_health through the function call?
main->callBaddieVector[BaddieClassObject]->CheckParasiteVector[ParasiteClassObject]->m_health
where CheckParasiteVector is generated within the class constructor for the BaddieClassObject.
I thought that vector calls were already created on the heap so I don't need to create a pointer unless I'm calling m_health through the function call?
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement