Path: utzoo!utgpu!water!watmath!clyde!att!rutgers!mailrus!uflorida!gatech!cumulus!hsu From: hsu@cumulus (Yung-Kao Hsu) Newsgroups: comp.lang.c++ Subject: Re: Can we hide the private part of a class ? Summary: programmers want to but can't Keywords: header dependency, efficiency. Message-ID: <1375@cumulus> Date: 3 Oct 88 15:52:02 GMT References: <1358@stratus* <1988Sep29.044111.16104@utzoo.uucp> <4223@polya.Stanford.EDU> Organization: Georgia Institute of Technology Lines: 36 In article <4223@polya.Stanford.EDU* shap@polya.Stanford.EDU (Jonathan S. Shapiro) writes: *In article <1368@cumulus> hsu@cumulus.UUCP (Yung-Kao Hsu) writes: ** **In article <1988Sep29.044111.16104@utzoo.uucp* henry@utzoo.uucp **(Henry Spencer) writes: ** ***The user can't access x, so seeing it won't do him much good. However, ** **This is true if all public functions won't return any pointer to x. **But, sometimes for efficiency reason, we will allow such bad pratice. * *The fact that a programmer can willfully break the type system is not *a good argument here. I can also use integer pointers as character *pointers. If the function returning pointer wants to be type-safe, *it should be declared as returning a pointer to a class member. In *that case, what Henry says continues to be true. * *Jon What I really should say in the previous posting is: the language should provide some mechanisms (i.e, hiding the data type definition) that prevent the programmer from mis-use even they want to. Also, your example is not quite convincing, since character and integer are not considered as "private" types but pre-defined public data types and we all know how they are implemented. ----- -- YUNG-KAO HSU School Of Infomation & Computer Science, Georgia Tech Atlanta GA30332 Internet: hsu@cumulus.gatech.edu CSNet: hsu%cumulus@gatech UUCP: ...!{akgua,allegra,amd,hplabs,seismo,ihnp4}!gatech!cumulus!hsu