Ethan Shapiro
Ethan Shapiro

Reputation: 103

C++ Member Declaration not found

I am an amateur c++ coder, and I started to use classes and Objects. I wanted to create a little "Program" that took in the birthday and name of the person and displayed it. I created a program you just enter the day, year, and month of your birthday and name & it displays it. I keep getting an error in People.h and People.cpp saying: "Member declaration not found" error, and candidates are: std::People::People(const std::People&) People.h and prototype for 'std::People::People()' does not match any in class 'std::People' People.cpp

I included Birthday.h and Birthday.cpp in two images at the bottom if you need those. Sorry for my messy formatting, this is my second post and i tried to make things readable, but I kinda failed. :P

My Main.cpp is:

#include "Birthday.h"
#include "People.h"
#include <iostream>
using namespace std;

int main() {

    Birthday birthObj(4,16,2002);

    People ethanShapiro("Ethan Shapiro", birthObj);

    return 0;
}

People.h is:

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

namespace std {

class People {
    public:
        People(string x, Birthday bo);
        void printInfo();
    private:
        string name;
        Birthday dateOfBirth;
};

}

#endif

People.cpp is:

    #include "People.h"

namespace std {

People::People(): name(x), dateOfBirth(bo) {
}

void People::printInfo(){
    cout << name << " is born in";
    dateOfBirth.printDate();
}

}

Birthday.h Birthday.cpp

Upvotes: 1

Views: 2968

Answers (1)

R Sahu
R Sahu

Reputation: 206567

The sole constructor of People is declared as:

    People(string x, Birthday bo);

and you are defining a constructor as:

People::People(): name(x), dateOfBirth(bo) {
}

The definition does not match any declaration.

You need to use:

People::People(string x, Birthday bo): name(x), dateOfBirth(bo) {
}

Upvotes: 2

Related Questions