Good morning everyone, I currently have an issue in my code, it crashes without any error output. I was hopping you could lend me a hand!
The issue occurs when I append an element at a vector, but not at the first iteration always at the second.
Here is my main code:
/*Various includes*/
int main(void)
{
int cmpt = 0;
std::vector<Commande> _vct;
Commande cmd;
while(cmpt < 15)
{
cout << "..." << endl;
_vct.push_back(cmd);
cout <<" test cmd" << _vct[cmpt].getBytes() << endl;
cmpt++;
}
return 0;
}
Here is the object's class that is appened to the vector:
Commande::Commande()
{
bytes="";
from="";
type="";
first_s="";
last_s="";
value=-1;
first_i=-1;
last_i=-1;
}
Commande::~Commande()
{
}
void Commande::toString()
{
cout << "=-_-=> from: '" << (this)->getFrom() << "', type: '" << (this)->getType() << "', value: '" << (this)->getValue() << "', bytes: '" << (this)->getBytes() << "'." << endl;
}
void Commande::fromStringToInteger()
{
(this)->setFirst_i(atoi((this)->getFirst().c_str()));
(this)->setLast_i(atoi((this)->getLast().c_str()));
}
And finally the .h of Commande.cpp:
#include <cstdlib>
#include <iostream>
#ifndef COMMANDE_H_
#define COMMANDE_H_
using namespace std;
class Commande
{
public:
Commande();
virtual ~Commande();
/*Various geters ans seters*/
void toString(void);
void fromStringToInteger();
private:
string bytes, from, type, first_s, last_s;
int value, first_i, last_i;
};
#endif /* COMMANDE_H_ */
Thank you all for your time!