500pts: Polymorphism help?
Posted on 2006-11-14
Can anyone help, i have declared some variables of type ToolWindow which belongs to a custom control in my class like so
private ToolWindow _explorerToolWindow, _userToolWindow, _alarmToolWindow;
All is fine, then under a method i assign these to actual control which actually inherits from ToolWindow hence
_explorerToolWindow= new twExplorer(); // this now is a toolwindow but actually is really a twExplorer which derives from toolwindow
(_explorerToolWindowas twExplorer).go(); // I have to do this to enable access to .go method.. otherwise its unavailable
but i don't think i am doing it right... Is there a way to assign my _explorerToolWindow directly to a twExplorer... or do i have to use the keyword "as" all the time?
I am a little confused, it is working using this way ... but i think i am going the long way round... there must be a way to automatically change the instance to be of type twExplorer and not toolWindow?
any advice or help really appreciated
thanks in advance