E0289 отсутствуют экземпляры конструктора "PERSON::PERSON", соответствующие списку аргументов main
Не могу никак понять в чем ошибка. Заранее благодарю
Главная страница
#include <iostream>
#include <string>
#include "PERSON.h"
using namespace std;
int main()
{
int nPerson;
cout << "How much Human you watn to created" << endl;
cin >> nPerson;
PERSON* human = new PERSON[nPerson];
string name = "Volodia";
string sex = "Man";
PERSON tmp(name, sex, { 28, 07, 2003 });
for (int i = 0; i < nPerson; i++) {
tmp.printPerson(human[i]);
}
}
Person.h
using namespace std;
#pragma once
class PERSON
{
private:
string Pib;
string sex;
int bDay[3];
public:
// Constructors
PERSON();
PERSON(string name);
PERSON(string name, string sex);
PERSON(string name, string sex, int* bday);
PERSON(const PERSON& other);
~PERSON();
// Input and Output
PERSON input();
void printPerson(PERSON& data);
};
PERSON.cpp
#include <iostream>
#include <string>
#include <stdio.h>
#include "PERSON.h"
using std::cout;
using std::cin;
using std::endl;
using std::string;
// Constructors
PERSON::PERSON() {
cout << "Created object without arguments!" << this << endl;
Pib = sex = NAN;
for (int i = 0; i < 3; i++) {
bDay[i] = 0;
}
}
PERSON::PERSON(string name) {
this->Pib = name;
}
PERSON::PERSON(string name, string sex) : PERSON(name) {
his->sex = sex;
}
PERSON::PERSON(string name, string sex, int* bday) : PERSON(name, sex){
cout << "You created a full Person!" << this << endl;
for (int i = 0; i < 3; i++) {
this->bDay[i] = bday[i];
}
}
PERSON::PERSON(const PERSON& other) {
cout << "Copy constructor!" << this << endl;
this->Pib = other.Pib;
this->sex = other.sex;
for (int i = 0; i < 3; i++) {
this->bDay[i] = other.bDay[i];
}
}
PERSON::~PERSON() {
cout << "Person deleted" << this << endl;
}
Ответы (1 шт):
Автор решения: Harry
→ Ссылка
{ 28, 07, 2003 } - это никак не указатель на int.
Замените, например,
PERSON tmp(name, sex, { 28, 07, 2003 });
на
int tmp_array[] = { 28, 07, 2003 };
PERSON tmp(name, sex, tmp_array);
и смотрите следующие ошибки...