Say I have a class foo, and that one of its fields is a pointer to an instance of itself:
class foo
{
int x;
foo y;
}
When the constructor for foo is called, I want it to initialize the value of the y field to the instance of foo that just got constructed.
foo()
{
y=THIS INSTANCE OF foo just now constructed
}
I'm not sure how to do this. Any suggestions?
class foo
{
int x;
foo y;
}
When the constructor for foo is called, I want it to initialize the value of the y field to the instance of foo that just got constructed.
foo()
{
y=THIS INSTANCE OF foo just now constructed
}
I'm not sure how to do this. Any suggestions?