Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!sun-barr!apple!vsi1!daver!tscs!tct!chip From: chip@tct.uucp (Chip Salzenberg) Newsgroups: comp.lang.c++ Subject: Re: private base classes (was Nonvirtual base classes in MI) Message-ID: <27B94BB0.5A0A@tct.uucp> Date: 13 Feb 91 14:22:40 GMT References: <1174@zinn.MV.COM> <64173@brunix.UUCP> <1991Feb8.220931.251@odin.corp.sgi.com> Organization: Teltronics/TCT, Sarasota, FL Lines: 33 According to linton@sgi.com (Mark Linton): > If you have a real example of "convenient" private inheritance, > I'd be interested in seeing it. In a real application I have two classes, SqlStmt and SqlCursor. SqlStmt is a private base class of SqlCursor. I would have made it public, but to maintain internal consistency I can allow only one member function of SqlStmt public, namely, SqlStmt::in(). However, SqlStmt::in() is actually several overloaded functions. Thus the declaration: class SqlCursor : private SqlStmt { public: SqlCursor(); ~SqlCursor(); SqlStmt::in; // other declarations... }; This declaration conveniently makes all the SqlStmt::in() functions public without needing to name them all. The use of inheritance instead of a SqlStmt member variable also implies that the member functions of SqlCursor can call member functions of SqlStmt without specifying "member.func()". Both of these aspects are convenience wins. -- Chip Salzenberg at Teltronics/TCT , "I want to mention that my opinions whether real or not are MY opinions." -- the inevitable William "Billy" Steinmetz