I have a class Person, and a class PEmployee. I want to store an object of the class Person within the PEmployee class. Both classes are in header files, and their constructors and member functions are in separate .cpp files. I also have a main.cpp file. I've provided all the code. I am getting the error:
undefined reference to 'Person::Person()'
in line 9 of PEmployee.cpp
Is this a syntax error or is my approach completely wrong? I have only just started on classes and oop, and have only really dealt with the concept of encapsulation. What is the correct way of doing this without "cheating", so to speak (using more advanced techniques)?
undefined reference usually means you are referring to something that is undefined. In this case a default constructor Person::Person() which does not exist.
you can fix it like this so you use the constructor you did provide...