Bueno, quise implementar el patron prototype con 2 prototipos de tv que hereda del prototipo TV. PrototipoLED y prototypePLASMA, pero no funciona.
Obtengo el error 101
no matching function for call to `prototipoLED::prototipoLED(prototipoTV)' y luego muestra los parametros del constructor, es el tipico error de los atributos en el constructor pero no se como se resuleve...
Aqui el codigo
Código C++:
Ver original#include <iostream>
using namespace std;
class prototipoTV{
protected:
string marca;
string modelo;
string color;
int resvert;
int reshori;
string TEC;
int brillomax;
int garantia;
public:
prototipoTV(string marcaTV,string modeloTV,string colorTV,string TECTV,
int resvertTV,int reshoriTV,int brillomaxTV,int garantiaTV){
marca=marcaTV;
modelo=modeloTV;
color=colorTV;
TEC=TECTV;
resvert=resvertTV;
reshori=reshoriTV;
brillomax=brillomaxTV;
garantia=garantiaTV;
};
virtual prototipoTV clonar();
void setMarca(string marcaTV){this->marca=marcaTV;};
void setModelo(string modeloTV){this->modelo=modeloTV;};
void setColor(string colorTV){this->color=colorTV;};
void setTEC(string TECTV){this->TEC=TECTV;};
void setResvert(int resvertTV){this->resvert=resvertTV;};
void setReshori(int reshoriTV){this->reshori=reshoriTV;};
void setBrillomax(int brillomaxTV){this->brillomax=brillomaxTV;};
void setGarantia(int garantiaTV){this->garantia=garantiaTV;};
};
class prototipoLED:public prototipoTV{
private:
int garantia;
public:
prototipoLED::prototipoLED(string marcaTV,string modeloTV,string colorTV,string TECTV,
int resvertTV,int reshoriTV,int brillomaxTV,int garantiaTV):prototipoTV(marcaTV,modeloTV,
colorTV,TECTV,resvertTV,reshoriTV,brillomaxTV,garantiaTV){
};
void getTipoTV(){
cout<<("soy un LED")<<endl;
};
prototipoTV clonar(){
//prototipoLED *LED2= new prototipoLED("A","A","A","A",1,1,1,1);
prototipoTV *LED2= new prototipoLED(*this);
/*LED2->setMarca(this->marca);
LED2->setBrillomax(this->brillomax);
LED2->setColor(this->color);
LED2->setModelo(this->modelo);
LED2->setReshori(this->reshori);
LED2->setResvert(this->resvert);
LED2->setTEC(this->TEC);
LED2->setGarantia(this->garantia);*/
return *LED2;
};
};
class prototipoPLASMA:public prototipoTV{
private:
int garantia;
public:
prototipoPLASMA::prototipoPLASMA(string marcaTV,string modeloTV,string colorTV,string TECTV,
int resvertTV,int reshoriTV,int brillomaxTV,int garantiaTV):prototipoTV(marcaTV,modeloTV,
colorTV,TECTV,resvertTV,reshoriTV,brillomaxTV,garantiaTV){
};
void getTipoTV(){
cout<<("soy un PLASMA")<<endl;
}
prototipoTV clonar(){
prototipoPLASMA *PLASMA2= new prototipoPLASMA("samsung","dff","negro","IPS",1280,720,12,24);
PLASMA2->setMarca(this->marca);
PLASMA2->setBrillomax(this->brillomax);
PLASMA2->setColor(this->color);
PLASMA2->setModelo(this->modelo);
PLASMA2->setReshori(this->reshori);
PLASMA2->setResvert(this->resvert);
PLASMA2->setTEC(this->TEC);
return *PLASMA2;
};
};
class Cliente{
public: static void obtenerTVs(){
prototipoLED *primerLED=new prototipoLED("samsung","dff","negro","IPS",1280,720,12,6);
prototipoPLASMA *primerPLASMA= new prototipoPLASMA("samsung","dff","negro","IPS",1280,720,12,6);
prototipoLED *listaLED[10];
prototipoPLASMA *listaPLASMA[10];
for (int x=0;x<10;x++){
// cout<<primerLED->clonar()<<endl;
listaLED[x]= (prototipoLED) primerLED->clonar();
// listaPLASMA[x]=(prototipoPLASMA) primerPLASMA->clonar();
listaLED[x]->getTipoTV();
};
};
};
int main(){
Cliente::obtenerTVs();
return 0;
};
estoy probando primero con LEd para luego hacer PLASMA.
Saludos