I got two classes, one named `Person` that I checked is working (I can create objects of that class so the problem should not be here).

I then have another class called `Family` with composition from `Person`:

**Family.h**

```
#include "Person.h"
class Family
{
public:
    Family();
    void printFamily();
private:
    Person dad_();
    Person mum_();
    Person son_();
    Person daughter_();

};

```

**Family.cpp**

```
#include "Family.h"
Family::Family()
{

}
void printFamily()
{
    dad_.printAll();
    mum_.printAll();
    son_.printAll();
    daughter_.printAll();
//printAll() is a function in the Person class that worked when 
//I tested it earlier with only the person class
}

```

But when i try to compile this I get an error:

```
left of '.printAll' must have class/struct/union
'son_' : undeclared identifier

```

This error goes for all the `.printAll()` calls in *family.cpp*.

I can't see why this wouldn't work, so I hope you can.

**Edit1:**

Ok i changed
 void printFamily()
to
 void Family::printFamily()

That removes one error, but i still get

```
left of '.printAll' must have class/struct/union

```

**Edit2**

Ah my bad with the Person calls i changed them to 

```
 Person dad_; 

```

and the same with the rest.

Seems like their might be an error with my Person class so i will post that also

**Person.h**

```
 #include <string>
 using namespace std;
 class Person
 {
 public:
 Person( const string & = "000000-0000", const string & = "N", const string & = "",const string & = "N");
~Person();
    void setFirstName(const string &);
    void setMiddleName(const string &);
    void setLastName(const string &);
    void getData(string &,string &,string &,string &);
    static int getNumberOfPersons();
    void printPartially() const;
    void printAll() const;
    bool checkForSameName(const Person &);
 private:
    string firstName_;
    string middleName_;
    string lastName_;
    string socialSecNumber_;
    static int numberOfPersons_;

 };

```

**Person.cpp**

```
 #include "Person.h"
 #include <iostream>

 int Person::numberOfPersons_ = 0;
 Person::Person( const string &sNumber, const string &firstName, const string &middleName,const string &lastName )
    :firstName_(firstName),middleName_(middleName),lastName_(lastName),socialSecNumber_(sNumber)
 {
    numberOfPersons_ ++;
 }
 Person::~Person()
 {
    numberOfPersons_--;
 }

 void Person::setFirstName(const string &firstName)
 { firstName_ = firstName; }

 void Person::setMiddleName(const string &middleName)
 { middleName_ = middleName; }
 void Person::setLastName(const string &lastName)
 {lastName_ = lastName;}

 void Person::getData(string &fName,string &mName,string &lName,string &sNumber)
{
 fName = firstName_;
 mName = middleName_;
 lName = lastName_;
 sNumber = socialSecNumber_;
 }

 int Person::getNumberOfPersons()
 {
    return numberOfPersons_;
 }

 void Person::printPartially() const
 {
    cout <<"Navn: "<<firstName_<<" "<<middleName_<<" "<<lastName_<<endl;
    cout <<"Født: ";
    for (int i = 0;i<6;i++)
    {
        cout <<socialSecNumber_.at(i);
    }
 }
 void Person::printAll() const
 {
    cout <<"Navn: "<<firstName_<<" "<<middleName_<<" "<<lastName_<<endl;
    cout <<"Personnr: "<<socialSecNumber_<<endl;
 }
 bool Person::checkForSameName(const Person &p)
 {
    if (p.firstName_ == firstName_ && p.middleName_ ==middleName_ && p.lastName_ == lastName_)
        return true;
    else
        return false;
 }

```

Now i am getting some new errors:

```
error C2011: 'Person' : 'class' type redefinition
see declaration of 'Person'
'Family::dad_' uses undefined class 'Person'

```

The "dad" error applies to the whole family