[gameprogrammer] Re: detecting class type at runtime

  • From: Amine Belahbib <xakiru@xxxxxxxxx>
  • To: gameprogrammer@xxxxxxxxxxxxx
  • Date: Wed, 18 Apr 2012 15:36:13 +0200

C++,  right ? here it is if i still remember

class A { ...

virtual char getClass(){
return 'A';
}
}
class B: public A {
virtual char getClass(){
return 'B';
}
}
class C: public A {
virtual char getClass(){
return 'C';
}
}

void dosomething(A *variable){
switch(variable->getCalss())
case
...
}




2012/4/18 <luo_hei@xxxxxxxx>

> I have the following:
>
> class A { ... }
> class B: public A {}
> class C: public A {}
>
> void dosomething(A *variable){
>
> }
>
> inside dosomething I need to know if variable is of type B or C at
> runtime, is there some portable way to do this?
>
>
> --
> Roger D. Vargas
> Using Gentoo Linux 2010
> La unica forma de encontrar los limites de lo posible es yendo mas
> alla de ellos, hacia lo imposible
>
> ---------------------
> To unsubscribe go to 
> http://gameprogrammer.com/**mailinglist.html<http://gameprogrammer.com/mailinglist.html>
>
>
>

Other related posts: