Hi
I’m trying to do instantiate a new object from custom class, but when I’m compilling i get these error :
error C2512 no appropriate default constructor available
this what I want to do :
UQuizQuestion *UquizAPI::getQuestion() {
UQuizQuestion *question = new UQuizQuestion();
question->setQuestion("test");
return question;
}
and this is my Question class :
#include “quizMobile.h”
#include “QuizQuestion.h”
UQuizQuestion::UQuizQuestion(const class FPostConstructInitializeProperties& PCIP)
: Super(PCIP)
{
this->nbAnswers = 0;
}
FString UQuizQuestion::getQuestion(){
return this->_question;
}
TArray<FString> UQuizQuestion::getAnswers(){
return this->_answer;
}
void UQuizQuestion::setQuestion(FString question){
this->_question = question;
}
void UQuizQuestion::setAnswers(TArray<FString> answers) {
this->_answer = answers;
this->nbAnswers = answers.Num();
}
void UQuizQuestion::addAnswer(FString answer){
this->_answer.Add(answer);
this->nbAnswers++;
}
and the Header :
#pragma once
#include "Object.h"
#include "QuizQuestion.generated.h"
/**
*
*/
UCLASS()
class UQuizQuestion : public UObject
{
GENERATED_UCLASS_BODY()
private:
FString _question;
TArray<FString> _answer;
int nbAnswers;
public:
UFUNCTION(BlueprintCallable, Category = "Quiz API")
FString getQuestion();
void setQuestion(FString question);
UFUNCTION(BlueprintCallable, Category = "Quiz API")
TArray<FString> getAnswers();
void setAnswers(TArray<FString> answers);
void addAnswer(FString answer);
};