Inheritance and Polymorhism through multiple abstract classes

Image if the UML_Class_Diagram

I'm trying to make a miniature program with an abstract factory creating either a External Contact or Internal Master, Teacher, Student Default. But I found myself facing a major problem.

Most of my classes are Abstract as you can see above the provided jpg (They have an "A" in front. "C" for Concrete). The reason for this is that the A classes will never be initiated but I need them to restrict and add functionality to the classes that derive from them.

The program worked perfectly until I decided to make the above envitioned classes Abstract instead of Concrete.

The issue is rather easy to explain given the information displayed in the UML_Class_Diagram.jpg:

I have class members stored in A_P_Internal that only should exist from that level and to the derived classes, so I figure it would be nonsensical to store methods connecting to those variables in A_Person.

I initialize in the following way:


// Make correct factory
std::unique_ptr<A_PersonFactory> internalFactory = A_PersonFactory::createFactory(A_PersonFactory::PERSON_TYPE::TEACHER);

// Make an empty list of persons
std::vector<std::unique_ptr<A_Person>> persons;

// Two temporary local variables used when testing calling the teacher creation below
const std::vector<std::string> privatePhoneNumbers{ "070-7654321", "071-7654321", "072-7654321" };
const std::vector<std::string> workPhoneNumbers{ "070-1234567", "071-1234567", "072-1234567" };

// Create a teacher and store the teacher in the list mentioned above
"John", "Smith", "Powell", "Josh, Rico",
"Some Street 99", 12345, "Atlantis", "", "Contact Name",
privatePhoneNumbers, workPhoneNumbers,
1984, 3, 19,
"Svalbard", 'm', "Spring the year 1489", "I was lazy enough to make that choice into my only choice"));

// Print some information from each teacher on the list


std::unique_ptr<A_Person> C_InternalFactory::createTeacherFull(
const std::string &firstNameVal,
const std::string &lastNameVal,
const std::string &lastNameTwoVal,
const std::string &middleNamesVal,
const std::string &streetAddressVal,
const int &postalCodeVal,
const std::string &cityVal,
const std::string &zipCodeVal,
const std::string &careOfVal,
const std::vector<std::string> &privatePhoneNumbersVal,
const std::vector<std::string> &workPhoneNumbersVal,
const int &yearOfBirthVal,
const int &monthOfBirthVal,
const int &dateOfBirthVal,
const std::string &placeOfBirthVal,
const char &genderVal,
const std::string &movedHereFromVal,
const std::string &movedHereBecauseOfVal)

auto teacher = A_PersonFactory::createPersonFull(

teacher->setFullInternalPerson(yearOfBirthVal, monthOfBirthVal, dateOfBirthVal, genderVal, placeOfBirthVal, movedHereFromVal, movedHereBecauseOfVal);

return teacher;

And I get this error error C2039: 'setFullInternalPerson': is not a member of 'A_Person'.

The error disapear when the classes are concrete or I add a pure virtual function called setFullInternalPerson A_Person. Neither of these sultions will scale well and they don't make any sense anyway. Is it impossible to first define my setFullInternalPerson in A_P_Internal and then override it in C_PIE_Teacher?

If I don't call the method setFullInternalPerson the console will output the following (I simply display the order the constructors and destructors are being called. I rewmoved some of the code in the middle since itäs redundant for this question.):

Person Factory: Constructor called Internal Factory: Constructor called Person: Constructor called Person Internal: Constructor called Employee: Constructor called Teacher: Constructor called Person: Constructor called Person External: Constructor called External Contact: Constructor called

Some redundant output that has nothing to do with this question.

Teacher: Destructor called Employee: Destructor called Person Internal: Destructor called External Contact: Destructor called Person External: Destructor called Person: Destructor called Person: Destructor called Internal Factory: Destructor called Person Factory: Destructor called

If you need to see more too understand (

Thankfull for an answer if you have one! Kind Regards// Alexander Karlsson