CConsoleBase implemented abstract class?

Login to reply to this topic.
Thu, 2008-04-10 12:23
Joined: 2008-04-03
Forum posts: 5

Hello,

I am relatively new with using Symbian, so maybe there´s a simple answer to my question.
I noticed that all methods of CConsoleBase are pure abstract, so any subclass should implement all these functions. On the other hand, it is possible to instantiate a CConsoleBase object, so actually all these functions (although declared = 0) do have an implementation.
Is there some design reason for this?
It makes it quite difficult to inherit from CConsoleBase. One should either do private derivation, or implement all of the methods one-self.
I´d be interested to know what´s the reason behind this.
Regards,

Machiel


Sun, 2008-04-27 21:27
Joined: 2008-03-12
Forum posts: 30
Re: CConsoleBase implemented abstract class?

It's not possible to instatiate a CConsoleBase object. If you have a look at console exe as created by Carbide it instatiates CConsole and not ConsoleBase like that:

TRAPD(createError, console = Console::NewL(KTextConsoleTitle, TSize(KConsFullScreen,KConsFullScreen)));

CConsole is a concrete implementation of CConsoleBase.
I don't think one would ever want to inherit a different concrete class from CConsoleBase, I don't see any reasons to do that.

But by design it's quite correct.
By having an abstract base class they are able to easily implement different consoles if they will have to. The functions which are virtual are those functions which would probably require different implementation on different consoles. Indeed, it's console-specific how to get a cursor position, get a keystroke etc.

  • Login to reply to this topic.