Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!asuvax!intertel!wohlenbe From: wohlenbe@intertel.UUCP (Greg Wohlenberg) Newsgroups: comp.lang.c++ Subject: Abstract Base Class Enforcement Keywords: class, abstract, c++ Message-ID: <358@intertel.UUCP> Date: 22 Mar 91 22:01:24 GMT Organization: Inter-Tel, Inc., Chandler, AZ Lines: 23 Hi, I've got a question. Say you have a base class that you want to be abstract. But, for one reason or another, it isn't convenient to make any of the class's virtual functions pure. (This would happen if all your virtual functions actually "do something" in the base class.) Given that you want to disallow instances of the abstract base class from being created, which of these alternatives is best? 1. Create a extra do-nothing function in the base class that is pure virtual. 2. Make the base class's no-parameter constructor "protected". This makes it so only derived classes are able to create instances of the base class (and therefore enforces the abstract characteristic of the base class). Or, is there another alternative that I am not aware of? Thanks, Greg Wohlenberg | Voice: (602) 961-9000 Inter-tel, Inc. | Fax: (602) 961-1370 6505 W. Chandler Blvd. | INTERNET: wohlenbe%intertel.uucp@asuvax.eas.asu.edu Chandler, Arizona, 85226 | UUCP: intertel!wohlenbe@asuvax.eas.asu.edu