Path: utzoo!attcan!uunet!lll-winken!lll-tis!ames!nrl-cmf!cmcl2!beta!unm-la!unmvax!turing.UNM.EDU!mike From: mike@turing.UNM.EDU (Michael I. Bushnell) Newsgroups: comp.lang.c++ Subject: Re: access functions Message-ID: <1027@unmvax.unm.edu> Date: 5 May 88 07:47:35 GMT References: <11152@mimsy.UUCP> <6590046@hplsla.HP.COM> Sender: news@unmvax.unm.edu Reply-To: mike@turing.UNM.EDU.UUCP (Michael I. Bushnell) Organization: University of New Mexico, Albuquerque Lines: 43 In article <6590046@hplsla.HP.COM> jima@hplsla.HP.COM ( Jim Adcock) writes: >Someone try to explain >to me what great advantages access functions have in the following >[trivialized to the ridiculous] example ???: > >class IntVal >{ > private: > int val; > public: > void setValue(int aval) {val = aval;} > int value() {return val;} >}; > >verses > >class IntVal >{ > public: > value; >}; Nothing, obviously. This code is better written as struct IntVal { public: value; }; Get the picture? If you think that you really NEED access functions, you might as well just make it a struct. N u m q u a m G l o r i a D e o Michael I. Bushnell HASA - "A" division 14308 Skyline Rd NE Computer Science Dept. Albuquerque, NM 87123 OR Farris Engineering Ctr. OR University of New Mexico mike@turing.unm.edu Albuquerque, NM 87131 {ucbvax,gatech}!unmvax!turing.unm.edu!mike