10. What you need to think about is what would happen if defs.h contained each of A-E, and c1.c and c2.c both #include defs.h, and you try to build c1.c and c2.c into an executable. Would you get some errors? Try it.

9. no idea, you'd have to RTFM. I *think* A-C are based on a linked list, making it D, but I'm not certain.

8. Did you try Googling? http://lmgtfy.com/?q=overloaded+function+c%2B%2B

7. D and E are both wrong. Where is the test in each of A-C? If it's at the start of the loop then the loop body might not be executed at all. If it's at the end then it has to go through the loop at least once before it gets to the test.

6. Very important this one if you want to avoid some really difficult to find bugs. E.

5. Duff question, because it depends on the compiler. If TRUE==1 then a is one possible answer, but it can also be true if x is zero and y is non-zero (because FALSE *is* zero, and x==y==x is equivalent to x==(y==x), or x==(TRUE or FALSE)). If TRUE==-1 then none of A-E because it would be true when x==-1 and y==-1 (as well as when x==0 and y!=x). But maybe a is the answer they're looking for.

4. Correct.

3. Another duff question. Undefined behaviour; the expression abuses the postincrement. You would have to run it in your compiler and see what the output is. In Microsoft Visual Studio this is equivalent to i+=j -=k*=i; i++;, so k*=i->k=0, j-=0->j=-1, i+=-1->i=4, i++->i=5. So i=5,j=-1,k=0. But if the postincrement happens after k*=i++ and before i+=j then the final value of i is 6.

2. Duff question, depends on what your tutor has said, which is probably wrong. Not e,d,b because C has them, and C isn't OO, a is dependent on your point of view (c makes assembly level programming easier), and probably not c either because exceptions aren't unique to C++. But maybe they're after c.

1. Another duff question? a: no, because a reference is actually a pointer but uses different semantics; b:no because you can use references in other contexts; c:no, this isn't a "difference statement"; d:no because vtables are about virtual functions not variables; e:no, because there IS a difference in the way they are used. Check your course notes, one of these statements will incorrectly be labelled as true.
mocha like this