• Advertisement

Archived

This topic is now archived and is closed to further replies.

pls answer this... A class that has a protected constructor:

This topic is 5943 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

a. cannot be used as a base class b. results in read-only objects c. must have a virtual destructor d. none of the above which letter is correct? thanks!

Share this post


Link to post
Share on other sites
Advertisement
Guest Anonymous Poster


the chicken crosses at midnight..

Share this post


Link to post
Share on other sites
c or d.

AFAIK there is no rule in the C++ language that says "If Thou Maketh A Class With A Protected Constructor, Thine Destructor Must Be Virtual", but since a class with a protected constructor is most likely an ADT from which you are deriving other useful classes, it is probably a good idea.

Share this post


Link to post
Share on other sites
hehe, sure, it''s a 60 item test, anyway pls, i want a sure answer, anyone?

Share this post


Link to post
Share on other sites
Well it''s a crap question. There is no requirement in the C++ language that a class with a protected constructor should have a virtual destructor, but in 99% of cases it is common sense. (off the top of my head, I can''t think of any cases where it isn''t common sense, can anyone else?)

So the correct answer depends on your teacher. If he is

a) a tosser who learnt C++ from ''Teach Yourself C++ in 21 days'' and is giving you questions directly out of the book, then the answer is probably c.

or

b) a tosser who actually knows and understands the syntax, but wants to ask you a trick question. In this case, the answer is d.

I''d put my money on c, even though technically d is the correct answer.

Share this post


Link to post
Share on other sites
There''s nothing wrong with TYSC++I21D - it just has a bad title.

Once there was a time when all people believed in God and the church ruled. This time is called the Dark Ages.

Share this post


Link to post
Share on other sites

  • Advertisement