I am aware that a function calling itself is recursive. But, is an object creating objects of it's own type recursive? Additionally, I have no intention of using this code as it will quite obviously cause problems, I'm only interested in whether or not it qualifies as recursion.
class Cell
{
Cell()
{
Cell c = new Cell();
}
}
Indeed it does. The Cell constructor will be called by itself, assuming that some calling code sets off the construction of a Cell instance.
Unless you block the recursion somehow (perhaps with a maximum instance limit), your program will eventually crash.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With