The following code throws the aforementioned error message at the line where an object is added to a vector:
include "palm.h"
include <vector>
using namespace std;
class forehead {
public:
void palmstrikesforehead(float x, float y, float z);
private:
vector<palm> palms;
};
void forehead::palmstrikesforehead(float x, float y, float z) {
Palm::Palm palm(x,y,z);
palms.push_back(palm); //Exception thrown if this line is not commented out.
}
The code works with a vector of integer type, but not with a vector of Palm type. What I would like to do is to anonymously add Palms to the vector (as in the java: arrayList.add(new Palm(x,y,z));. How may that be done?
The class name seems to be
palm. So you should writeOr you could construct the palm in-place: