For Programmers: Free Programming Magazines  


Home > Archive > Visual Studio > March 2005 > How can I call an enclosing class's function?









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author How can I call an enclosing class's function?
Eric A. Johnson

2005-03-26, 3:59 am

Hi All,

I have a class, ConsoleWindow, that is a member of another class,
ConsoleLib, like so:
class ConsoleLib
{
public:
class ConsoleWindow
{
public:
ConsoleWindow(HANDLE Screen, COORD Start, COORD Size, bool Border);
~ConsoleWindow();
// etc.
}
void OutputString(char *String);
// etc.
}
How would I call a ConLib function from a ConsoleWindow constructor or
function? I'm trying to call OutputString from ConsoleWindow's constructor.
Is there any way of doing this?

On a side note, should the subclass ConsoleWindow be public or private?

Thanks,
Eric


Kelly

2005-03-31, 8:58 pm

Use "ConsoleWindow::OutputString()".

Make ConsoleWindow private, then add public accessor-methods to
ConsoleLib to retrieve information from ConsoleWindow.



"Eric A. Johnson" <nothere@dontlookforme.com> wrote in message
news:ks31e.15551$C47.5018@newssvr14.news.prodigy.com...
> Hi All,
>
> I have a class, ConsoleWindow, that is a member of another class,
> ConsoleLib, like so:
> class ConsoleLib
> {
> public:
> class ConsoleWindow
> {
> public:
> ConsoleWindow(HANDLE Screen, COORD Start, COORD Size, bool

Border);
> ~ConsoleWindow();
> // etc.
> }
> void OutputString(char *String);
> // etc.
> }
> How would I call a ConLib function from a ConsoleWindow constructor or
> function? I'm trying to call OutputString from ConsoleWindow's

constructor.
> Is there any way of doing this?
>
> On a side note, should the subclass ConsoleWindow be public or private?
>
> Thanks,
> Eric
>
>



Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com