0

My code is as follows

supportCrew.cpp

#include <iostream>
#include <sstream>
#include <fstream>

#include "compDay.h"
#include "Competion.h"
#include "Events.h"
#include "Location.h"
#include "Octathlon.h"
#include "Person.h"
#include "supportCrew.h"
#include "theTeam.h"
#include "weatherSystem.h"

supportCrew::supportCrew(sportsPsychologist newPsychologist, Physiotherapist newPhysio, trainer trainerOne, trainer trainerTwo) {

this->Psychologist = newPsychologist;
this->physio = newPhysio;
this->trainer1 = trainerOne;
this->trainer2 = trainerTwo;

}

Person.cpp

#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <chrono>
#include <random>
#include <algorithm>

#include "compDay.h"
#include "Competion.h"
#include "Events.h"
#include "Location.h"
#include "Octathlon.h"
#include "Person.h"
#include "supportCrew.h"
#include "theTeam.h"
#include "weatherSystem.h"

Physiotherapist::Physiotherapist(std::string name, int age, int experience, int recovery, int readiness) : Person(name, age, experience)
{
    this->readinessScore = readiness;
    this->recoveryScore = recovery;
};

sportsPsychologist::sportsPsychologist(std::string name, int age, int experience, int pressure, int injury, int successFail) : Person(name, age, experience)
{

    this->pressurescore = pressure;
    this->injuryscore = injury;
    this->successfailscore = successFail;
};

trainer::trainer(std::string name, int age, int experience, std::string specialization, int performance, int consistency) : Person(name, age, experience)
{

    this->specialization = specialization;
    this->performanceScore = performance;
    this->consistencyScore = consistency;
};

I thought I set up my linking properly but when I compile my program I receieve the following error

supportCrew.cpp:(.text+0x25): undefined reference to `sportsPsychologist::sportsPsychologist()'
supportCrew.cpp:(.text+0x35): undefined reference to `Physiotherapist::Physiotherapist()'
supportCrew.cpp:(.text+0x45): undefined reference to `trainer::trainer()'
supportCrew.cpp:(.text+0x57): undefined reference to `trainer::trainer()'

The h files for both cpp files

supportCrew.H

#ifndef SUPPORTCREW
#define SUPPORTCREW
#include "Person.h"

class supportCrew {

public
sportsPsychologist Psychologist;
Physiotherapist physio;
trainer trainer1;
trainer trainer2;

public:
supportCrew(sportsPsychologist,Physiotherapist,trainer,trainer);
supportCrew();

};

#endif

person.h

#ifndef PERSON
#define PERSON

class Person
{

public:
    std::string name;
    int experience; //in years
    int age;
    Person(std::string pName, int pAge, int pExperience)
    {
        name = pName;
        age = pAge;
        experience = pExperience; //years of experience
    };

    Person();
    virtual ~Person(){};
};

class Physiotherapist : public Person
{

public:
    int recoveryScore;
    int readinessScore;

    Physiotherapist(std::string pName, int pAge, int pExperience, int recoveryScore, int readinessScore);
    Physiotherapist();
   
};

class sportsPsychologist : public Person
{

public:
    int pressurescore;
    int injuryscore;
    int successfailscore;
    sportsPsychologist(std::string pName, int pAge, int pExperience, int pressureScore, int injuryScore, int successfailScore);
    sportsPsychologist();
 
};

class teamManager : public Person
{

public:
    teamManager(std::string pName, int pAge, int pExperience);
    teamManager();
};

#endif

If anyone could let me know what part of my code is causing this error and how I can fix it it would be greatly appreciated :)

davidlingg2000
  • 107
  • 1
  • 5
  • You already asked the same question before. I'm unclear why you expect a different result this time. – cigien Oct 25 '20 at 22:24
  • @cigien the issue last time was different – davidlingg2000 Oct 25 '20 at 22:26
  • Why? I still see no definitions of the default constructors. – cigien Oct 25 '20 at 22:28
  • @cigien if you read my last question you'll see that issue was resolved – davidlingg2000 Oct 25 '20 at 22:29
  • Was it? You haven't accepted that answer, and you don't seem to have incorporated the changes either. – cigien Oct 25 '20 at 22:31
  • This error is caused by the fact, that you declared a `default constructor` for `Person`, `Physiotherapist` etc. but you did not define them. You can easily fix it by writing e.g. `Person() = default;` instead of the declaration in the class definition. – UweJ Oct 25 '20 at 22:44

0 Answers0