Jump to content

Cast e Arrays

Recommended Posts


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? :/


Edited by pmg
Falta LP no GeSHi

Share this post

Link to post
Share on other sites
((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

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • 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.