Path: utzoo!attcan!uunet!tut.cis.ohio-state.edu!zaphod.mps.ohio-state.edu!brutus.cs.uiuc.edu!psuvax1!rutgers!bellcore!rruxh!aaron From: aaron@rruxh.UUCP (Akman) Newsgroups: comp.lang.c++ Subject: comp.lang.c++ Message-ID: Date: 8 Jun 90 13:26:35 GMT Sender: news@bellcore.bellcore.com Distribution: comp Organization: Bellcore Lines: 52 A few C++ Questions: In Stroustrup pp. 163-166: 1. Is it still true that setting 'this' and zeroing it tell the compiler not to use the free store? I understand it this way (am I correct?): The compiler checks the constructor for 'this = something' and if it finds that it won't bother getting storage for 'this' on entry to the constructor; otherwise the constructor is called with a 'this' pointer that has already been given some storage. 2. Can someone explain the infinite loop in 5.5.6? I'm a little confused. 3. In 5.5.8, we're familiar with this variable-sized object trick from the good 'ol days of C, but it's a little confusing to see: class char_stack { // whatever... char s[1]; public: char_stack(int sz); // and so on... }; because we (I) think of structure members as being contiguous data in memory. I realize that char_stack is not data, but a function member. My question is: What is really happening internally here? I'm guessing that all the data parts are collected in contiguous memory, no per-object space is allocated for any of the function members, but some housekeeping type pointer helps an object find its class functions in a shared place. So, really, there is nothing that comes after 'char s[1]' in that example? 4. Do I have this right? char_stack s1(100); char_stack s2 = s1; // from p. 157 s2 = s1; The 1st one says: allocate a char_stack and call the constructor that expects an int (or whatever). The second says, allocate a char_stack and call the X(X&) constructor. The second case is NOT an assignment. The 3rd case says call 'operator=' for s2 with s1 as its argument. Is the default 'operator=' bitwise copy, or is it undefined? I understand why these assignments are dangerous in the example shown. -- ----------- Aaron Akman, 201-699-8019, bellcore!rruxh!aaron, RRC 4D-728