roblema estranho ao preencher uma lista com objetos em C +
Criei uma classePatient
e quero preencher uma lista dePatients
com objetos que eu criei através do construtor explícito. No entanto, recebo um erroType name is not allowed
quando tento preencher olist<Patient>
usando o `= {} (lista de inicializadores). Gostaria de perguntar o que estou fazendo de errado?
#include "pch.h"
#include <iostream>
#include <string>
#include <list>
using namespace std;
class Patient {
string name;
string birthday;
int visits;
public:
Patient(string n, string b, int v) {
name = n;
birthday = b;
visits = v;
}
};
list<Patient> sp = {
Patient a("I.Petrov", "21.12.02", 4),
Patient b("D.Stoyanov", "12.02.97", 7),
Patient c("K.Dimitrov", "07.08.90", 1)
};
int main()
{
return 0;
}