• Courses
  • Tutorials
  • Jobs
  • Practice
  • Contests

C++ Misc

Question 11

The associativity of which of the following operators is Left to Right, in C++ ?
  • Unary Operator
  • Logical not
  • Array element access
  • addressof

Question 12

Which of the following is not correct (in C++) ?

  1. Class templates and function templates are instantiated in the same way
  2. Class templates differ from function templates in the way they are initiated
  3. Class template is initiated by defining an object using the template argument
  4. Class templates are generally used for storage classes
  • (1)
  • (2), (4)
  • (2), (3), (4)
  • (4)

Question 13

Predict the output of following C++ program C
#include<iostream>
using namespace std;

union A {
  int a;
  unsigned int b;
  A() { a = 10; }
  unsigned int getb() {return b;}
};

int main()
{
    A obj;
    cout << obj.getb();
    return 0;
}
  • Compiler Error: union can\'t have functions
  • Compiler Error: can\'t access private members of A
  • 10
  • garbage value

Question 14

Which of the following is true about inline functions and macros.
  • Inline functions do type checking for parameters, macros don\'t
  • Macros are processed by pre-processor and inline functions are processed in later stages of compilation.
  • Macros cannot have return statement, inline functions can.
  • Macros are prone to bugs and errors, inline functions are not.
  • All of the above

Question 15

CPP
#include<iostream>
using namespace std;
int main ()
{
       int cin;
       cin >> cin;
       cout << \"cin\" << cin;
       return 0;
}
Thanks to Gokul Kumar for contributing this question.
  • error in using cin keyword
  • cin+junk value
  • cin+input
  • Runtime error

There are 15 questions to complete.

Last Updated :
Take a part in the ongoing discussion