Reputation: 43
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();
}
}
Upvotes: 3
Views: 98
Reputation: 234685
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.
Upvotes: 3