1

hi i was making a program with 3 classes and when i was using a member initialization list i got an error saying "no instance of overloaded function "people::people" matches the specified type:

MAIN.cpp

 #include <iostream> #include "conio.h" #include <string> #include "birthday.h" #include "people.h" using namespace std; void main(){ birthday birthObj (30, 06, 1987); people me("The King",birthObj); _getch(); } 

BIRTHDAY.h

 #pragma once class birthday { public: birthday(int d, int m, int y); void printdate(); private: int month; int day; int year; }; 

BIRTHDAY.cpp

 #include "birthday.h" #include <iostream> #include "conio.h" #include <string> using namespace std; birthday::birthday(int d, int m, int y) { month = m; day = d; year = y; } void birthday::printdate() { cout << day << "/" << month << "/" << year; } 

PEOPLE.h

 #pragma once #include <iostream> #include "conio.h" #include <string> #include "birthday.h" using namespace std; class people { public: people(string x, birthday bo); void printInfo(); private: string name; birthday dateOfBirth; }; 

PEOPLE.cpp

 #include "people.h" #include <iostream> #include "conio.h" #include <string> #include "birthday.h" using namespace std; people::people() : name(x), dateOfBirth(bo) { } void people::printInfo() { cout << name << " was born on "; dateOfBirth.printdate(); } 
1
  • Which line generates the error? Commented Aug 24, 2011 at 13:14

5 Answers 5

1

People.cpp should be:

people::people(string x, birthday bo) : name(x), dateOfBirth(bo) { } 
Sign up to request clarification or add additional context in comments.

Comments

1

You havn't implemented the people(string x, birthday bo); constructor. in your PEOPLE.cpp, change

people::people() : name(x), dateOfBirth(bo) 

to

people::people(string x, birthday bo) : name(x), dateOfBirth(bo) 

Comments

1

Your constructor in PEOPLE.cpp has the wrong signature:

It should be:

people::people(string x, birthday bo) 

Instead of:

people::people() 

Comments

0
 people::people() : name(x), dateOfBirth(bo) { } 

You have forgotten your arguments to this constructor.

Comments

-1

poeple ctor declaration and definition doesn't match!

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.