raghu said:
Can anyone please tell why this code doesn't work.
struct google
{
int x;
struct google y; //line 4
};
It shows an error at line 4.
It works 'y' is a pointer..
Why so?
Build a house. Inside the house, build an exact replica of the house,
including the exact replica, which must of course include the exact
replica, which must include the exact replica, which m...
Once you've worked out why you can't do that, I think you'll realise why
you can't have a struct that contains an instance of itself.
It works when y is a pointer for the same reason that, whilst a house might
struggle to contain a house, it will normally have enough space for an
address book.
--
Richard Heathfield <http://www.cpax.org.uk>
Email: -http://www. +rjh@
Google users: <http://www.cpax.org.uk/prg/writings/googly.php>
"Usenet is a strange place" - dmr 29 July 1999