Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!think.com!spool.mu.edu!uunet!mcsun!ukc!servax0!sersun1!whisd From: whisd@sersun1.essex.ac.uk (Whiteside S D B) Newsgroups: comp.lang.c++ Subject: Public vs Private header files in C++ Message-ID: <5243@servax0.essex.ac.uk> Date: 3 Jun 91 12:23:13 GMT Article-I.D.: servax0.5243 Sender: news@servax0.essex.ac.uk Reply-To: whisd@essex.ac.uk (Whiteside S D B) Organization: University of Essex, Colchester, UK Lines: 30 I wonder if anyone has any suggestions on this: Modula-2, for example, provides a separate "public" interface to the user's of a module. The "definition module" is like a header file - it shows what functions are available to the user, but it need not show private functions nor the design of the data structures it uses. In C++ you have private/public/protected members, but the header file must contain reference to all these things, regardless of whether the user needs to see them or not. This means: i) security might be compromised: it's possible for the user to "hack" into the data structures ii) when implementation-specific features are changed (such as, in a recent case with me, where I wanted a different sized array in my class) which do not change the semantics of the class, the user has to be recompiled as it has access to the same information as the class itself. iii) The user is burdened with too much detail when using the header file as a documentation aid. Can these be overcome with existing C++ constructs? Or would a change in the language allowing "incomplete" class declarations for public header files be needed? Thanks for any comments. Simon Whiteside