* Re: (member) function returning pointer to functions like itself?
[not found] <38E1C63B.6827CA77@dvv.org>
@ 2000-03-29 6:57 ` Dima Volodin
0 siblings, 0 replies; only message in thread
From: Dima Volodin @ 2000-03-29 6:57 UTC (permalink / raw)
To: gcc
Well, I've ended up with
///////////////// cut /////////////////
#include <iostream>
class Fptr {
class Fptr (*ptr) ();
public:
Fptr (Fptr (*p) ()) : ptr (p) {}
Fptr operator () () {
return (*ptr) ();
}
};
Fptr f1 ();
Fptr f2 ();
Fptr f1 () {
cout << "f1" << endl;
return f2;
}
Fptr f2 () {
cout << "f2" << endl;
return f1;
}
int
main () {
Fptr f (f1);
f = f ();
f = f ();
f = f ();
}
///////////////// cut /////////////////
but it's not exactly what I wanted - I get a pointer to a class here,
which is not as efficient as pointer to function. So the original
question still stands.
Cheers!
Dima
Dima Volodin wrote:
>
> Consider:
>
> ...
> T f1 ();
> T f2 ();
> ...
> T fN ();
> ...
> T f1 () {
> ...
> return f2;
> }
> ...
> T fN () {
> ...
> return f1;
> }
> ...
> T t;
> ...
> t = (*t) (); // I really want it like this
> ...
>
> How do I define T?
>
> Cheers!
>
> Dima
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2000-03-29 6:57 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
[not found] <38E1C63B.6827CA77@dvv.org>
2000-03-29 6:57 ` (member) function returning pointer to functions like itself? Dima Volodin
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).