Hi guys can someone clear this up for me,I made a Birthday object inside the People class I thought this would work as I included the Birthday.h file in the People.cpp file and people.h but I get an error,the error is
line 8 error:field 'bo' has incomplete type 'people
line 8 error: definition of implicitly-declared 'people::people()'
here is my code
people.h
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
#ifndef PEOPLE_H
#define PEOPLE_H
#include "birthday.h"
class people
{
public:
people(bo);
protected:
private:
birthday birthObject;
};
#endif // PEOPLE_H
I have a theory, but I'm not at a computer that has compiler so I'm not able to test the theory.
The constructor for birthday class requires 3 integers as parameters, so for the constructor definition in people.cpp, wouldn't you have to provide 3 integer parameters for birthObject object like shown below? I'm guessing you are trying to copy the variables of bo object to the variables of birthObject object. Am I right?
Like I said, I don't have a compiler at the moment to test this idea, so if you can test it for me, I would appreciate it. I apologize in advance if this is incorrect or if I made a wrong assumption about what you are trying to accomplish.
Just looking at your code snippet, it looks like it should work. I would recommend a copy constructor for your birthday class though.
Edit: Uh oh, you have a circular dependency present.
birthday.h includes people.h
people.h includes birthday.h
The solution to this problem is to either redesign the data interactions or use a technique called forward declaration.
However, in your case you do not actually need to include people.h in birthday.h, so just remove that include.