Is there a way to make a class recursive?

前端 未结 2 1879
挽巷
挽巷 2021-01-16 21:19

So I would like to create a class that can have an object which type is itself. Something like this:

class foo {

    foo Avalue = foo();
    foo Bvalue = fo         


        
2条回答
  •  一生所求
    2021-01-16 21:56

    The problem with that is that the foo inside foo would contain a foo which would contain a foo which would contain a foo which would contain a foo which would contain a foo which would contain a foo which would contain a foo which would contain a foo which would contain a foo which would contain a foo which would contain a foo which would contain a foo which would contain a foo which would contain a foo which would contain a foo which would contain a foo which would contain a foo which would contain a foo which would contain a foo which would contain a foo which would contain...

提交回复
热议问题