Keyword

Result: 265 questions

Which lines below should not compile?

1 struct A
2 {
3    A(int x) : n(x) {}
4    int n;
5 };
6
7 int main(int argc, char** argv)
8 {
9    A a1;
10   A a2(2);
11   A a3(a2);
12   return 0;
13 }
Quiz

Which of the following statements are true?

  1. Conversion functions of class A convert from class A into another type
  2. Conversion functions of class A are used to convert from another given type into class A
  3. Converting constructors must be callable with a single argument
Quiz

What gets printed for the value of z?

#include <iostream>

struct Foo
{
  Foo(int n) : x(n++), y(n++), z(n++) {}
  int x;
  int y;
  int z;
};

int main(int argc, char** argv)
{
  Foo f(3);

  std::cout << "x: " << f.x << std::endl;
  std::cout << "y: " << f.y << std::endl;
  std::cout << "z: " << f.z << std::endl;

  return 0;
}
Quiz

What gets printed?

#include <iostream>

struct Car
{
  Car() : price(20000) {}
  Car(double b) : price(b*1.1) {}
  double price;
};

struct Toyota : public virtual Car
{
  Toyota(double b) : Car(b) {}
};

struct Prius : public Toyota
{
  Prius(double b) : Toyota(b)  {}
};

int main(int argc, char** argv)
{
  Prius p(30000);

  std::cout << p.price << std::endl;

  return 0;
}
Quiz

What is the maximum number of implicitly defined constructors that this struct will have?

struct A
{
  A(A& a) { }
  A(double d) {}
  int val;
};
Quiz

What gets printed?

#include <iostream>

struct A
{
  A() : val(0) {}
  A(int v) : val(v) {}
  A(A& a) : val(a.val) {} 

  int val;
};

int main(int argc, char** argv)
{
  const A a1;
  const A a2(5);
  const A a3 = a2;

  std::cout << a1.val + a2.val + a3.val << std::endl;

  return 0;
}
Quiz

What gets printed?

#include <iostream>

struct A
{
  A() : val() {}
  A(int v) : val(v) {}
  A(A a) : val(a.val) {} 

  int val;
};

int main(int argc, char** argv)
{
  A a1(5);
  A a2(a1);

  std::cout << a1.val + a2.val << std::endl;

  return 0;
}
Quiz

Which lines below are ill-formed?

1 #include <iostream>
2
3 struct A
4 {
5   A(int& var) : r(var) {}
6
7   int &r;
8 };
9
10 int main(int argc, char** argv)
11 {
12   int x = 23;
13
14   A a1(x);
15
16   A a2 = a1;
17
18   a2 = a1;
19
20   return 0;
21 }
Quiz

What gets printed?

#include <iostream>

int foo(int i)
{
  return 2;
}

double foo(double d)
{
  return 4.0;
}

struct Computer
{
  int foo(int i)
  {
    return 8; 
  }
};

struct Gateway : public Computer
{
  double foo(double d)
  {
    return 16.0; 
  }
};

int main(int argc, char** argv)
{
  Gateway g;

  std::cout << foo(1) + foo(1.0) + g.foo(1) + g.foo(1.0) << std::endl;

  return 0;
}
Quiz

What gets printed?

#include <iostream>

struct mybase
{
  int x;
  
  template <int RANGE>
  virtual void print()
  {
    std::cout << RANGE + x + 1 << std::endl;
  }
};

struct myderived : public mybase
{
  template <int RANGE> 
  void print()
  {
    std::cout << RANGE + x + 2 << std::endl;
  }
};

int main(int argc, char** argv)
{
  mybase* b = new myderived;

  b->x = 1;

  b->print<5>();

  return 0;
}
Quiz

Algorithms are designed using combinations of three main building blocks (control structures), called...

Quiz

Which of the following code constructs vector of length 11 ?

Quiz

The _________ function is a kind of “constructor function” that can be used to construct other functions.

Quiz

In the Django Template Language, the {% ... %} notation provides for the inclusion of arbitrary Python code, with structures like 'for', 'if', etc.

Quiz

Consider the program segment:

Age DB 100

MOV Age,123

What is the memory-addressing mode of the first operand in the MOV instruction?

Quiz

The instruction AND AH,11110111 is equivalent to:

Quiz

Which of the following instruction(s) can be performed only in CX register:

Quiz

The data elements in structure are also known as what?

Quiz

What will be used when terminating a structure?

Quiz

What will happen when the structure is declared?

Quiz

© 2017 QuizBucket.org