wmm@sdti.UUCP (11/20/87)
The Book, speaking of static data members of classes on p. 275, says, "[a static member] cannot be of a class with a constructor." Cfront does not enforce this restriction, and I cannot see any reason for the restriction in the first place. Is this phrase in The Book incorrect, out-of-date, or yet to be implemented? If the latter, what is the reason for the restriction? -- Non-disclaimer: My boss and I always see eye-to-eye (every time I look in the mirror). ...!genrad!mrst!sdti!wmm
spalding@uiucdcsp.UUCP (11/25/87)
It's ok for a static object to be a "member of" a class with a constructor, but not ok for a static member object to be "of" a class with a constructor. Thus, in the following example, x is "of" class inner, which has a constructor, and therefore may not be a "member of" class outer. It doesn't matter whether class outer has a constructor or not. This restriction is probably imposed because it is not clear when the constructor should be called. The following example was run with cfront 1.2.1 on a VAX: class inner { int n; inner(); }; class outer { static inner x; }; CC test.c: "test.c", line 8: sorry, not implemented: static member outer::x of class inner with constructor 1 error
wmm@sdti.UUCP (William M. Miller) (11/27/87)
In article <77300006@uiucdcsp> spalding@uiucdcsp.cs.uiuc.edu writes: >It's ok for a static object to be a "member of" a class with a constructor, >but not ok for a static member object to be "of" a class with a constructor. Aha! When I read "No initializer can be specified for a static member, and it cannot be of a class with a constructor," I puzzled a bit over what "of" meant. I ended up parsing it by repeating the antecedent of "it," i.e., "cannot be [a member] of a class with a constructor." Interpreting "be of" to mean "have a type which is" is novel, but it certainly makes better sense than my interpretation. Thanks! -- Non-disclaimer: My boss and I always see eye-to-eye (every time I look in the mirror). ...!genrad!mrst!sdti!wmm