locked
Managed classes and nesting

    Question

  • One of my C++ components wants to return a structure with extended information about the operations result. This return type is currently a public ref class with a couple of read-only properties.

    In ye olden days, I would have declared it as a nested class of the component class, since its destructor is private and it should only be instantiated by its parent class during one specific operation. But as it apparently isn't possible to have public nested classes within a managed class (I hope this is the correct terminology to apply here?), I had to declare the traditional "outer" class as a friend class of the "inner" class and put them on the same level.

    This strikes me as somewhat sub-optimal and I was hoping that maybe someone on the forums could recommend a better way to design this.

    All the best

    Marcus

    Monday, April 16, 2012 1:55 PM

All replies

  • Hello,

    I would like to change this thread type as discussion, because I think there may be no exact answer for this question.

    Thanks for your understanding,

    Best regards,
    Jesse


    Jesse Jiang [MSFT]
    MSDN Community Support | Feedback to us

    Tuesday, April 17, 2012 6:43 AM