Hi everyone how are you ?
So I need a little trick or tip of how to do this: I have some classes in my project like Class A, Class B, Class C, etc; and I have a class that will comunicate me with one of then named Class D for sample see the code below:
int ClassD:
egaQuantidadeCanais(LPSTR pClasse) throw(...){
try{
int iloQtde = 0;
LPVOID lpvloObj = NULL;
//
if (strcmp(pClasse, "1 - Dialogic Analógica"
== 0 || strcmp(pClasse, "2 - Dialogic Digital"
== 0){
lpvloObj = new ClassA;
iloQtde = ((ClassA)lpvloObj).PegaQtdCanais();
}
else if (strcmp(pClasse, "3 - TAPI Modem"
== 0){
lpvloObj = new ClassB;
iloQtde = ((ClassB)lpvloObj).PegaQtdCanais();
}
else{
lpvloObj = new ClassC;
iloQtde = ((ClassC)lpvloObj).PegaQtdCanais();
}
return iloQtde;
}
catch(...){
dwgeErr = GetLastError();
return -1;
}
}
the compiler accept the code until the line lpvloObj = new cCtoUraDialogicSpring; but do not accept next line saying: " 'type cast' : cannot convert from 'LPVOID' to 'cCtoUraDialogicSpring' "
I want to know if is possible this code and if no how can I make a class that will be intermediate between many other tah have same methods (parametrs and returns) ???
Very Thanks,
Danilo Ameida
So I need a little trick or tip of how to do this: I have some classes in my project like Class A, Class B, Class C, etc; and I have a class that will comunicate me with one of then named Class D for sample see the code below:
int ClassD:
try{
int iloQtde = 0;
LPVOID lpvloObj = NULL;
//
if (strcmp(pClasse, "1 - Dialogic Analógica"
lpvloObj = new ClassA;
iloQtde = ((ClassA)lpvloObj).PegaQtdCanais();
}
else if (strcmp(pClasse, "3 - TAPI Modem"
lpvloObj = new ClassB;
iloQtde = ((ClassB)lpvloObj).PegaQtdCanais();
}
else{
lpvloObj = new ClassC;
iloQtde = ((ClassC)lpvloObj).PegaQtdCanais();
}
return iloQtde;
}
catch(...){
dwgeErr = GetLastError();
return -1;
}
}
the compiler accept the code until the line lpvloObj = new cCtoUraDialogicSpring; but do not accept next line saying: " 'type cast' : cannot convert from 'LPVOID' to 'cCtoUraDialogicSpring' "
I want to know if is possible this code and if no how can I make a class that will be intermediate between many other tah have same methods (parametrs and returns) ???
Very Thanks,
Danilo Ameida