Jump to content
carvalho2707

Cast e Arrays

Recommended Posts

carvalho2707

boas, tenho o seguinte pedaço de codigo:

no ponto.h

Tipos* _listas[10];

e adicionei elementes assim:

_listas[0] = (TipoA*) new TipoA(0,-50,0);
_listas[1] = (TipoB*) new TipoB(0,20,0);
_listas[2] = (TipoB*) new TipoB(-20,20,0);
_listas[3] = (TipoB*) new TipoB(20,20,0);

como é que eu consigo aceder ao _listas[0] para executar uma funcao que apenas percence ao tipo A? :/

obrigado

Edited by pmg
Falta LP no GeSHi

Share this post


Link to post
Share on other sites
HappyHippyHippo
((TipoA *) _listas[0])->foo();

Edited by HappyHippyHippo

IRC : sim, é algo que ainda existe >> #p@p

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...

Important Information

By using this site you accept our Terms of Use and Privacy Policy. We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.