Featured post
C++ a class to be used only by another class -
i'm building class (class a) needs able create number of instances of class (class b) in course of operation, class b used few member functions of class a, , never used outside of class. how should class b best defined? practical / reasonable make private member of class a? intended purpose of nested classes, or parting spirit of construct?
thanks, wyatt
edit: on further consideration, i'm not asking best practice, personal project. want include class b member of class encapsulation standpoint - seems reasonable class wholly subordinate should in fact part of owning class.
what i'm wondering whether or not reasonable use-case nested classes? if not, purpose of nested classes?
one possibility define namespace called detail
inside namespace put classes. e.g.
// public_namespace_detail.hpp namespace public_namespace { namespace detail { class b { ... }; } } // public_namespace.hpp #include "public_namespace_detail.hpp" namespace public_namespace { class { detail::b b; ... }; }
- Get link
- X
- Other Apps
Comments
Post a Comment