Problem with Composition

Hello, first of all I am completely newbie.^^b

Below are the code of I believe: Composition
Error found[3]:::'Birthday' hasn't been declared
::'Birthday' does not name a type
::no matching function for call to 'Person::Person(const char[11],Birthday& )

And this is my code:

MAIN CPP:

#include <iostream>
#include <cmath>
#include <ctime>
#include "Birthday.h"
#include "Person.h"

using namespace std;

int main()
{
Birthday birthObj(12,22,1995);
Person aqimPerry("Aqim Perry",birthObj);
aqimPerry.printPerson();




cin.get();
return 0;
}

-----------------------------------------------------------------------
BIRTHDAY HEADER:

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



using namespace std;



class Birthday
{
public:
Birthday(int m,int d,int y);
void printDate();
protected:
private:
int month;
int day;
int year;
};

#endif // BIRTHDAY_H
----------------------------------------------------------------------

BIRTHDAY CPP:

#include "Birthday.h"
#include "Person.h"
#include <iostream>
#include <cmath>
#include <ctime>

using namespace std;


Birthday::Birthday(int m,int d,int y)

{
month = m;
day = d;
year = y;
}

void Birthday::printDate()
{
cout << month << "/" << day << "/" << year << endl;
}

----------------------------------------------------------------------------
PERSON HEADER:

#ifndef PERSON_H
#define PERSON_H
#include "Birthday.h"
#include <iostream>
#include <string>
#include "Person.h"

using namespace std;


class Person
{
public:
Person(string x, Birthday ob);
void printPerson();
protected:
private:
string name;
Birthday dateOfBirth;
};

#endif // PERSON_H
---------------------------------------------------------------------------

PERSON CPP:

#include "Person.h"
#include "Birthday.h"
#include <iostream>
#include <cmath>
#include <ctime>
#include <string>


using namespace std;

Person::Person(string x, Birthday ob)
: name(x), dateOfBirth(ob)
{

}

void Person::printPerson()
{
cout << name << "was born on: ";
dateOfBirth.printDate();
}
----------------------------------------------------------------------
I was brainstorming eversince yesterday to solve the error =\.But ended up head over heels
Last edited on
you have a plethora of unnecessary include statements. hell, even your Person.h file itself has an include "person.h" statement. you should also avoid using namespace directive in header files. i'm pretty sure all i did was get rid of those and it compiled fine.
Aqim Perrywas born on: 12/22/1995 

you need space before was
1
2
3
4
5
void Person::printPerson()
{
cout << name << " was born on: ";
dateOfBirth.printDate();
}

or
1
2
3
4
5
void Person::printPerson()
{
cout << name << " " << "was born on: ";
dateOfBirth.printDate();
}
Topic archived. No new replies allowed.