From kdevelop-devel Tue Mar 09 21:15:54 2004 From: Sascha Herrmann Date: Tue, 09 Mar 2004 21:15:54 +0000 To: kdevelop-devel Subject: Re: Someone mentioned accessor methods? Message-Id: <404E340A.3000809 () web ! de> X-MARC-Message: https://marc.info/?l=kdevelop-devel&m=107886709010442 Steven T. Hatton wrote: > Also, C++ers tend to simply use the name of the member field as the name of > the retrieval (getter) method. Agreed? > > What about passing a reference verses passing a value; to the mutator > (setter)?; as the return value? > > What about constness? > > Does someone have a paradigm for this they would like to share? Hi, i wont claim to set up a paradigm but in my eyes that should look like: class test { public: test(); ~test(); // get... const double& getSize() const; // set... (for "big" structures or whenever copying takes to long) void setSize(const double& newValue); // maybe better for standard types void setSize(const double newValue); protected: double m_Size; }; setters should be void because modern error handling should be done with exceptions (that`s what i think!). To improve things further we should create a template for get/setters so anybody can choose his favorite style. bye sascha PS: i am away untill sunday, so do not expect any answers from me next days ;-) _______________________________________________ Kdevelop-devel mailing list Kdevelop-devel@barney.cs.uni-potsdam.de http://barney.cs.uni-potsdam.de/mailman/listinfo/kdevelop-devel