I have a vector that takes in a class object but when I try to push back the object I have created into the vector I am getting these problems and don't know how to getnaround it. Can anyone help me please ?
void populate( std::vector<NV*> vNav, NV *nVess);
creating the object class
NV vPB;
object class variables matching up
vPB.name = namE;
vPB.type = typE;
vPB.length = lengtH;
vPB.speed = speeD;
vPB.range = rangE;
vPB.serialNum = serialNuM;
vPB.serialNum = beaM;
vPB.displacement = displacemenT;
vPB.draft = drafT;
vPB.isActive = isActivE;
namE = name;
typE = type;
lengtH = length;
speeD = speed;
rangE = range;
serialNuM = serialNum;
beaM = beam;
displacemenT = displacement;
drafT = draft;
isActivE = isActive;
vNav.push_back(vPB);
keep getting error error C2664: cannot convert parameter 1 from 'N_V::NV' to 'N_V::NV *&&'
and also keep getting error IntelliSence no instance of overload function
The vector is expecting a pointer to an object whereas the vPB you are pushing back is not a pointer to an object but rather the object itself.
The minimum you can do to fix this is:
NV* vPB = new NV();
vPB->name = namE;
... and similarly for all the members you need to initialize ...
vNav.push_back(vPB);
Secondly the vNav vector is only going to exist within the context of that function because it is being passed by value. You probably want to take the argument by reference. This means changing your function's signature to:
void populate( std::vector<NV*>& vNav, NV *nVess);
Lastly it's not advisable to use naked pointers if you can help it. Try looking into shared_ptr and unique_ptr as a more advanced step to ensure that the object's lifetime is correctly managed and you don't leak memory allocations.