Pros and cons of using nested C++ classes and enumerations?

前端 未结 13 2204
悲&欢浪女
悲&欢浪女 2020-11-29 23:43

What are the pros and cons of using nested public C++ classes and enumerations? For example, suppose you have a class called printer, and this class also store

13条回答
  •  感情败类
    2020-11-30 00:19

    I can see a con for nested classes, that one may better use generic programming.

    If the little class is defined outside the big one, you can make the big class a class template and use any "little" class you may need in the future with the big class.

    Generic programming is a powerful tool, and, IMHO, we should keep it in mind when developing extensible programs. Strange, that no one has mentioned this point.

提交回复
热议问题