I’m having a hard time creating a class using the constructor. Not sure what’s happening. Sometimes it loads, sometimes it doesn’t; not sure what’s going on.
This is my .h from that class:
ScreenBasics(int _answersFader, int _answersFaderVel, ofPoint _answersPos, size_t _numberOfanswers, string *_answersText, ofPoint _questionPos, string _questionText, bool _isHovered, bool _isClicked);
And this is my .cpp from that class:
ScreenBasics::ScreenBasics(int _answersFader, int _answersFaderVel, ofPoint _answersPos, size_t _numberOfAnswers, string *_answersText, ofPoint _questionPos, string _questionText, bool _isHovered, bool _isClicked, string _pathToFont):answersFader(_answersFader), answersFaderVel(_answersFaderVel), answersPos(_answersPos), numberOfAnswers(_numberOfAnswers),answersText(new string[numberOfAnswers]),questionPos(_questionPos), isHovered(_isHovered), isClicked(_isClicked){
answersText = _answersText;
for(int i = 0; i < numberOfAnswers; i++){
//we create our text
ofTrueTypeFont tmp;
answers.push_back(tmp);
answers[i].loadFont(_pathToFont, 24);
// we create our boundary box
ofRectangle box;
answersBox.push_back(box);
}
}
And this is how I create it on my ofApp.cpp:
int answersFader3 = 0;
int answersFader3Vel = 2;
ofPoint answersPos3 = ofPoint(( width / 2 ) - ( width / 10 ),( height / 2 ) - ( height / 5 ));
size_t numberOfAnswers3 = 3;
string answersText3[] = {"1.Unisex", "2. Female", "3.Male"};
ofPoint questionPos3 = ofPoint(( width / 2 ) - ( width / 8), ( height / 2) - ( height / 3 ));
string questionText3 = "What Gender's perfume are you looking for?";
bool isHovered3 = false;
bool isClicked3 = false;
// screen3 was created as a pointer in the .h file ScreenBasics *screen3;
screen3 = new ScreenBasics(answersFader3, answersFader3Vel, answersPos3, numberOfAnswers3, answersText3, questionPos3, questionText3, isHovered3, isClicked3, pathToFont);
Sometimes when I create the app it thrown me this error:
libc++abi.dylib: terminating with uncaught exception of type std::bad_alloc: std::bad_alloc.
Any thoughts?