I’m a computer science student. I know “conflicting return type specified” usually means you’re using a function before it’s declared but this one is a little different. Due to strict assignment guidelines, I’m implementing a task scheduler (our own multi-threader) and in one class called Task, in Task.h we have :
void Task::Start(){
int * returnval = new int;
*returnval = pthread_create(&thread_id,NULL,tfunc,this);
delete returnval;
}
then in another file, schedulable.h, we have:
int Schedulable::Start(){
try{
Task::Start();
return 0;
}catch(int e) { return 1; }
}
When I compile it, I have a “conflicting return type” error:
In file included from scheduler.H:59, from task_test_step2.cpp:9: schedulable.H:162: error: conflicting return type specified for ‘virtual int Schedulable::Start()’ task.h:157: error: overriding ‘virtual void Task::Start()’
Any ideas how I can get this to stop happening?
The problem is that
Schedulable::StartoverridesTask::Startand changes the return type fromvoidtoint. You probably want to makeTask::Startreturn an int too: