From owner-freebsd-hackers Thu Dec 11 18:43:05 1997 Return-Path: Received: (from root@localhost) by hub.freebsd.org (8.8.7/8.8.7) id SAA07200 for hackers-outgoing; Thu, 11 Dec 1997 18:43:05 -0800 (PST) (envelope-from owner-freebsd-hackers) Received: from smtp01.primenet.com (smtp01.primenet.com [206.165.6.131]) by hub.freebsd.org (8.8.7/8.8.7) with ESMTP id SAA07195 for ; Thu, 11 Dec 1997 18:42:57 -0800 (PST) (envelope-from tlambert@usr02.primenet.com) Received: (from daemon@localhost) by smtp01.primenet.com (8.8.8/8.8.8) id TAA17185; Thu, 11 Dec 1997 19:42:16 -0700 (MST) Received: from usr02.primenet.com(206.165.6.202) via SMTP by smtp01.primenet.com, id smtpd017158; Thu Dec 11 19:42:13 1997 Received: (from tlambert@localhost) by usr02.primenet.com (8.8.5/8.8.5) id TAA07290; Thu, 11 Dec 1997 19:42:08 -0700 (MST) From: Terry Lambert Message-Id: <199712120242.TAA07290@usr02.primenet.com> Subject: Re: Why so many steps to build new kernel? To: j_mini@efn.org Date: Fri, 12 Dec 1997 02:42:07 +0000 (GMT) Cc: jkh@time.cdrom.com, ksmm@cybercom.net, freebsd-hackers@FreeBSD.ORG In-Reply-To: <19971211021856.61158@micron.mini.net> from "Jonathan Mini" at Dec 11, 97 02:18:56 am X-Mailer: ELM [version 2.4 PL23] Content-Type: text Sender: owner-freebsd-hackers@FreeBSD.ORG X-Loop: FreeBSD.org Precedence: bulk > 3) C++ does not implement data hiding. Sure, you have opaque structs, > but you cannoy make an opaque class. That is, you cannot have a class > defined where you know how to interface with the functions, but not > the details of the internal data. Because you have to define the > private data within the same scope as the public interface, private > datatypes aren't possible. This is incorrect. global.h: #define interface struct /* no virtual destructor needed*/ myOpaqueClass.h: interface myOpaqueClass { virtual int function1( int arg1, char *arg2) = 0; virtual int function2( char *arg1) = 0; }; extern myOpaqueClass *createOpaqueClassObject(); myImplementationClass.cc #include "global.h" #include "myOpaqueClass.h" class myImplementationClass : public myOpaqueClass { private: /* * Private data not defined in the scope of the * public interface. */ int somedata; public: myImplementationClass(); /* constructor*/ ~myImplementationClass(); /* destructor*/ int function1( int arg1, char *arg2); int function2( char *arg1); }; /* * Public interface; use shared object technology to select * between implementation class instances for a given opaque * class... */ myOpaqueClass * createOpaqueClassObject() { myImplementationClass *instance; intstance = new myImplementationClass; return( (myOpaqueClass *)instance; } /* * constructor */ myImplementationClass::myImplementationClass() { } /* * destructor */ myImplementationClass::myImplementationClass() { } /* * implementation class specific implementation of pure * virtual base class interface "function1"... */ int myImplementationClass::function1( int arg1, char *arg2)) { ... } /* * implementation class specific implementation of pure * virtual base class interface "function2"... */ int myImplementationClass::function2( char *arg1) { ... } Terry Lambert terry@lambert.org --- Any opinions in this posting are my own and not those of my present or previous employers.