> But I'mtoo stupid. I have a struct, which contains a pointer to itself as an
> element. How to write this. I once knew, but now I fail. It's a shame! :-(
In C++ Land we do it like this:
struct StupidSolution {
int i;
struct StupidSolution *self;
StupidSolution(int num) : i(num), self(this) { }
};
But maybe you really wanted to do a tree:
struct TreeNode {
int i;
struct TreeNode *parent, *left, *right;
TreeNode(int num, TreeNode *par=NULL) : i(num), parent(par), left(0),
right(0) { }
};
And if you doing it old fashioned in C:
struct StupidSolution {
int i;
struct StupidSolution *self;
};
struct StupidSolution *sol=(struct StupidSolution)malloc(sizeof(struct
StupidSolution));
sol->i=3;
sol->self=sol;
-- ---> Dirk Jagdmann ----> http://cubic.org/~doj -----> http://llg.cubic.org _______________________________________________ Linux-audio-dev mailing list Linux-audio-dev@email-addr-hidden http://lists.linuxaudio.org/mailman/listinfo/linux-audio-devReceived on Thu Jul 10 20:15:05 2008
This archive was generated by hypermail 2.1.8 : Thu Jul 10 2008 - 20:15:05 EEST