Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Multiple Type Class ...

Status
Not open for further replies.

daniloa

Programmer
Nov 23, 2001
27
BR
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::pegaQuantidadeCanais(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
 
you can cast 'LPVOID' to 'SomeClass*', not to 'SomeClass' and not to 'cSomeClassInstance'

Ion Filipski
1c.bmp
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top