
Patron prototype: como implementarlo
Publicado por giuil (3 intervenciones) el 04/10/2015 13:02:28
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...
estoy probando primero con LEd para luego hacer PLASMA.
Saludos
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...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
#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();
system("pause");
return 0;
};
estoy probando primero con LEd para luego hacer PLASMA.
Saludos
Valora esta pregunta


0