Quantcast
Channel: ScapeCode » C++
Viewing all articles
Browse latest Browse all 5

A Simple C++ Quiz

$
0
0

Recently some people have been pestering me to post back up my C++ quizzes. So…without further ado here is the first one. The answers will be posted later.

  1. Given the following three lines of code, answer these questions
    int* p = new int[10];
    int* j = p + 11;
    int* k = p + 10;
    1. Is the second line well defined behavior?
    2. If the second line is well defined, where does the pointer point to?
    3. What are some of the legal operations that can be performed on the third pointer?
  2. What output should the following lines of code produce?
    int a = 10;
    std::cout<<a<<a++<<--a;
  3. Assuming the function called in the following block of code has no default parameters, and that no operators are overloaded, how many parameters does it take? Which objects are passed to it?
    f((a, b, c), d, e, ((g, h), i));
  4. Assuming the function called in the following block of code takes an A* and a B*, what is potentially wrong with the code?
    f(new A(), new B());

Viewing all articles
Browse latest Browse all 5

Latest Images

Trending Articles





Latest Images