sehe

http://testyourprogrammingskills.blogspot.com/

Dec 15th, 2011
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.71 KB | None | 0 0
  1. Q3. WTF? q cannot be deleted, since it is _not_ a pointer
  2.  
  3. Q4. WTF? What's the deal. Making a site that looks like it useful. Than got lazy about it. Good thing you didnt forget the ads
  4.  
  5. Q5. WTF? The compiler will error because there is no <cstudio> header; secondly, cclass is not a keyword. Thirdly, `A, `~ and `B are malformed character literals, no matter how many times you use them.
  6. Fourthly, the classes lack trailing `;` (both)
  7.  
  8. Lastly the whole shebang is unspecified, because the standard doesn't say in which order the global statics will be destructed. This is known as the Static Initialization Fiasco. The output may well become detached before the destructors for ::b and ::a run.
  9.  
  10. Q6. You can only compile one of the constructors. They both suck equally (since there is no protection against copying A nor B). That left, the initializer list is slightly less deadly - since it will leak 256 fewer bytes at construction. Never mind the leakage on destruction.
  11.  
  12. Q7. The correct answer isn't listed. It should be, nonstatic, nonconst member _fields_.
  13.  
  14. Q8. Poor you. And the question doesn't even have anything to do with C++
  15.  
  16. Q9. Unspecified. There is no vtable in the C++ standard. There might be (usually are) in an implementation, where this then becomes, implementation defined or undefined. I reckon most implementations will store a pointer to an error routine (aborting with 'a pure virtual function was called')
  17.  
  18. Q10. Runtime error? Most likely Bus Error or Segmentation Fault. That is _not_ a runtime error. Also, technically, it is just undefined behaviour, complete with nasal demons. Oh, and pedantically, there is no output. So the answer is ""
  19.  
  20. I say, this pop quiz could use some improvement. Good luck.
Add Comment
Please, Sign In to add comment