From yechiel Fri Jun 13 13:01:17 2003 Subject: Re: Questions regarding classes To: Date: Fri, 13 Jun 2003 13:01:17 +0300 (IDT) To your questions: > Dear Yechiel, > Here are some questions: > 1) What happens before what: The execution of the constructor OR all of > the initializations of the local variables? I know that all of the As I said in class, initializations (during Ctor) happen _before_ the body of the Ctor is executed. It is done in the order of appearance of (data/object)-members in the class definition. This happens _always_ - whether the initialization is explicit in the initialization list or by default-Ctor, for those members that do not appear in the initialization list. > initializations should be in the constructor, yet there are some local > variables that demand immediate initialization. Notably const members and references. > 2) Suppose there is a class with 20 attributes, all of them private, of > course. I think that it's not so good to write 40 Get and Set functions. > What are the alternatives? Maybe not writing 20 attributes? ;-> Well, seriously, if an object (class) has 20 attributes it is highly probable (in fact, I cannot think otherwise) that they are naturally grouped into few groups that deserve to become classes (hence objects) in their own right. Therefore, the original class will have much fewer attributes. Regarding the Get-Set problem, I advice you to read a discussion that appeared on accu-general discussion list (ACCU - Association of C & C++ Users) which I had the privilege to somewhat contribute to. It appears on my "Small Interesting Items" page, http://www.cs.technion.ac.il/users/yechiel/CS/Interesting.html and its direct URL is http://www.cs.technion.ac.il/users/yechiel/CS/Interesting/Encapsulation.mail > > Thank you very much for your attention, > . Enjoy Yechiel -------------------------------------------------------------------------------- Have you looked at recent updates to "Bad Books Amusement Park" ? Try http://www.cs.technion.ac.il/users/yechiel/CS/BadBooksC+C++.html Yechiel M. Kimchi XXXX@xxxxx Faculty Comp. Sc. The Technion, Haifa, 32000 IL Office: (04) 829 4226 FAX: +(972) 4 822 1128 Homepage: http://www.cs.technion.ac.il/users/yechiel/