I have a base product class with a few private members and a public getter that derived classes inherit. I would like to disqualify instantiation, since the class is intended for use with an abstract factory. I thought protected con/destructors might work, however, this breaks my smart pointers. Friending seems like a useful disaster. Is there a well-known solution to this, or should I resign myself to the fact that any client who has the factory injected must also know enough to instantiate the base product?
class Product { private: char type_name; char size_name; public: Product(char, char); virtual ~Product() {} void Print(); };
https://stackoverflow.com/questions/67351847/is-it-a-necessary-trade-off-that-using-smart-pointers-requires-my-class-to-be-pu May 02, 2021 at 07:53AM
没有评论:
发表评论