Date: Fri, 12 Dec 1997 02:42:07 +0000 (GMT) From: Terry Lambert <tlambert@primenet.com> To: j_mini@efn.org Cc: jkh@time.cdrom.com, ksmm@cybercom.net, freebsd-hackers@FreeBSD.ORG Subject: Re: Why so many steps to build new kernel? Message-ID: <199712120242.TAA07290@usr02.primenet.com> In-Reply-To: <19971211021856.61158@micron.mini.net> from "Jonathan Mini" at Dec 11, 97 02:18:56 am
next in thread | previous in thread | raw e-mail | index | archive | help
> 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.
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199712120242.TAA07290>