Re: Questions on latest homework answers


[ Follow Ups ] [ Post Followup ] [ CS2704 Web Discussion Board ] [ FAQ ]

Posted by Daniel Longest on April 06, 2001 at 00:05:33:

In Reply to: Questions on latest homework answers posted by M. Heffner on April 04, 2001 at 17:58:03:

: First, on question number 19, I think the answer should be 2, rather
: than 5 (2 + 3). Answer 3 states "to construct an object's sub-objects
: before the rest of the object is constructed," however this is not
: entirely correct. The sub-objects of a class are always implicilty
: constructed prior to the rest of the object, the member initializer
: list allows the programmer to explicitly call a specific constructor
: of the sub-object. The member initializer list does NOT allow the
: programmer to change the default construction order.

The question does not say that this is the only way to construct the subobjects but that is one of its usages, to construct the subobjects with initial values before the rest of the object is constructed. All construction that is done with initialization lists is guaranteed to finish before the body of the constructor is finished executing. The fact that you don't have to use that method to construct subobjects has no bearing on this answer.

: Second, on question number 16, yes it's obvious that class Y has two
: elements (Y::f and X::m) however the addition of the part
: "(considering all access protections)" implies that the question is
: looking for how many elements class Y can directly access. If the
: question was only asking for how many total elements class Y has, than
: I can't see any reason for the additional statement to consider access
: protections. This addition only made the question ambiguous, as seen
: from another post on the discussion board concerning question #16.

I'm confused as to how "considering all access protections" can be seen as ambiguous, to me it clarifies that they want to know the number of data members in the derived object. The fact is the derived object has two but it is unable to access them directly should not make you think that they want only the ones that can be directly accessed.

Daniel



Follow Ups:



Post a Followup

Name:
E-Mail:

Subject:

Comments:

Optional Link URL:
Link Title:
Optional Image URL:


[ Follow Ups ] [ Post Followup ] [ CS2704 Web Discussion Board ] [ FAQ ]