Mail Archives: djgpp/1998/02/14/22:48:00
From: | "John M. Aldrich" <fighteer AT cs DOT com>
|
Newsgroups: | comp.os.msdos.djgpp
|
Subject: | Re: super
|
Date: | Sat, 14 Feb 1998 22:44:11 -0500
|
Organization: | Two pounds of chaos and a pinch of salt.
|
Lines: | 42
|
Message-ID: | <34E6648B.1162@cs.com>
|
References: | <6c5gqi$ajt AT nnrp4 DOT farm DOT idt DOT net>
|
NNTP-Posting-Host: | ppp209.cs.com
|
Mime-Version: | 1.0
|
To: | djgpp AT delorie DOT com
|
DJ-Gateway: | from newsgroup comp.os.msdos.djgpp
|
Chia wrote:
>
> Ok all, I've got two classes.
>
> class foo
> class foo_2
>
> Now, if class foo has a class foo_2 in it,
>
> class foo {
> public:
> foo_2 *mr_foo;
> void something(void);
> };
>
> is there a way to have mr_foo call a function, something(), in foo?
> Thanks!
Damn! I am totally off tonight. I missed the point of your question
twice! Okay... what you want is for the member functions of class foo_2
to be able to use the member functions of class foo, when an object of
class foo_2 is a member of class foo. This is conceptually impossible,
because foo's data and member functions are not in scope in foo_2. It
would be possible to include a pointer to a foo object in foo_2, and
invoke its member functions through the pointer. However, that seems a
ridiculously complex and error-prone way to handle things, and you'd
have to do a lot of finagling to even get the two pointers pointing to
each other. It would help to understand the application you have in
mind; I might be able to suggest an entirely different way of handling
things.
P.S.: This is a C++ question, not a DJGPP question, and is therefore
off-topic for this newsgroup. comp.lang.c++ or comp.lang.c++.moderated
would be better places to ask.
--
---------------------------------------------------------------------
| John M. Aldrich | "A generation which ignores history |
| aka Fighteer I | has no past--and no future." |
| mailto:fighteer AT cs DOT com | |
| http://www.cs.com/fighteer | - Lazarus Long |
---------------------------------------------------------------------
- Raw text -