From: Warren Young Date: July 14 2007 4:50am Subject: Re: Connection::connect() interface is changing List-Archive: http://lists.mysql.com/plusplus/6790 Message-Id: <469855F8.6080800@etr-usa.com> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Warren Young wrote: > class Connection ... { > public: > class TCP { > public: > TCP(host, user, port, etc...); > } > Connection(const TCP& tcp); > > #ifdef MYSQLPP_PLATFORM_WINDOWS > class NamedPipes { > public: > NamedPipes(); > } > Connection(const NamedPipes& np); > #else > class DomainSockets { > public: > DomainSockets(path); > } > Connection(const DomainSockets& ds); > #endif > } I'm a dunce. The solution is staring me right in the face: inheritance! This is a perfect is-a relationship. Just make one lightweight subclass of Connection for each connection style. Then, depending on how we're feeling about code compatibility, we can either retain the candy machine ctor in the parent class, or make Connection's ctor private and make the subclasses call mysql_real_connect() themselves.