Tengo una clase llamada Pokemon, en donde le puse 2 constructores, el primero es de iniciallización y el otro recibe el nombre de un pokemon y lo completa
class Pokemon{
private:
string type;
string advantage1;
string advantage2;
string resistance1;
string resistance2;
string resistance3;
float damageattack;
float health;
string name;
public:
//Constructor
Pokemon(float health, float damageattack, string type, string advantage1, string advantage2, string resistance1, string resistance2, string resistance3, string name){
this->type = type;
this->advantage1 = advantage1;
this->advantage2 = advantage2;
this->health = health;
this->damageattack = damageattack;
this->name = name;
}
Pokemon(string name){
this->name=name;
if(name == "Caterpie"){
this->type="Bug";
this->advantage1 = "Grass";
this->advantage2 = "Psychic";
this->resistance1 = "Fighting";
this->resistance2 = "Grass";
this->resistance3 = "Ground";
this->health = 393;
this->damageattack = 55;
}
else if(name == "Metapod"){
this->type="Bug";
this->advantage1 = "Grass";
this->advantage2 = "Psychic";
this->resistance1 = "Fighting";
this->resistance2 = "Grass";
this->resistance3 = "Ground";
this->health = 419;
this->damageattack = 45;
}
}
Ahora en la función principal quiero instanciar un arreglo de la clase Pokemon, pero me envía un error.No me permite compilar.
int main(){
Pokemon p1[2] = {"Metapod","Caterpie"};
}
¿Cual es el problema?, supongo que tiene que ver con los 2 constructores
Este es el error que me sale.
error: conversion from 'const char [8]' to non-scalar type 'Pokemon' requested
error: conversion from 'const char [9]' to non-scalar type 'Pokemon' requested