Start New Discussion within our Software Development Community

Here is the code first:


#include "People.h"
#include "Birthday.h"
using namespace std;

People::People(string x, Birthday bo)
: name(x), birth(bo)

void People::People()
    cout << name << "was born on" << birth.printDate();


#ifndef PEOPLE_H
#define PEOPLE_H
#include "Birthday.h"
class People
        People(string x, Birthday bo);
        void printInfo();

        string name;
        Birthday birth;

#endif // PEOPLE_H

The problem is I get these errors when compling the code:

Compiling: src/People.cpp
In file included from /home/deofamily/Documents/Project/src/People.cpp:1:0:
/home/deofamily/Documents/Project/include/People.h:8:23: error: expected ‘)’ before ‘x’
/home/deofamily/Documents/Project/include/People.h:12:9: error: ‘string’ does not name a type
/home/deofamily/Documents/Project/src/People.cpp:6:15: error: expected constructor, destructor, or type conversion before ‘(’ token
/home/deofamily/Documents/Project/src/People.cpp:11:21: error: return type specification for constructor invalid
/home/deofamily/Documents/Project/src/People.cpp:11:21: error: definition of implicitly-declared ‘People::People()’

What am I doing wrong?

People class doesn't have a declaration for the default constructor, String needs to be defined through its namespace.

std::string X. And std::name because you do not have "using namespace std;"

In the people class under the public inheritance, add:


And finally, PrintInfo has no definition.

This question has already been answered. Start a new discussion instead.