61. What will be the output of the following C++ code?
#include <iostream>
using namespace std;
int main ()
{
try
{
throw 20;
}
catch (int e)
{
cout << "An exception occurred " << e << endl;
}
return 0;
}
#include <iostream>
using namespace std;
int main ()
{
try
{
throw 20;
}
catch (int e)
{
cout << "An exception occurred " << e << endl;
}
return 0;
}62. What will be the output of the following C++ code?
#include <iostream>
using namespace std;
int main ()
{
int n;
n = 43;
cout << hex << n << endl;
return 0;
}
#include <iostream>
using namespace std;
int main ()
{
int n;
n = 43;
cout << hex << n << endl;
return 0;
}63. Which is the correct statement about pure virtual functions?
64. Where are allocators implemented?
65. What will be the output of the following C++ code?
#include <iostream>
using namespace std;
class A
{
public:
A(int n )
{
cout << n;
}
};
class B: public A
{
public:
B(int n, double d)
: A(n)
{
cout << d;
}
};
class C: public B
{
public:
C(int n, double d, char ch)
: B(n, d)
{
cout <<ch;
}
};
int main()
{
C c(5, 4.3, 'R');
return 0;
}
#include <iostream>
using namespace std;
class A
{
public:
A(int n )
{
cout << n;
}
};
class B: public A
{
public:
B(int n, double d)
: A(n)
{
cout << d;
}
};
class C: public B
{
public:
C(int n, double d, char ch)
: B(n, d)
{
cout <<ch;
}
};
int main()
{
C c(5, 4.3, 'R');
return 0;
}66. Which keyword is used to handle the expection?
67. What will be the output of the following C++ code?
#include <iostream>
using namespace std;
template <class T>
class Test
{
private:
T val;
public:
static int count;
Test() {
count++;
}
};
template<class T>
int Test<T>::count = 0;
int main()
{
Test<int> a;
Test<int> b;
Test<double> c;
cout << Test<int>::count << endl;
cout << Test<double>::count << endl;
return 0;
}
#include <iostream>
using namespace std;
template <class T>
class Test
{
private:
T val;
public:
static int count;
Test() {
count++;
}
};
template<class T>
int Test<T>::count = 0;
int main()
{
Test<int> a;
Test<int> b;
Test<double> c;
cout << Test<int>::count << endl;
cout << Test<double>::count << endl;
return 0;
}68. Which of the following is correct about templates?
69. What is the syntax of an explicit call for a template? Assume the given template function.
template<class T, class U>
void func(T a, U b)
{
cout<<a<<"\t"<<b<<endl;
}
template<class T, class U>
void func(T a, U b)
{
cout<<a<<"\t"<<b<<endl;
}70. How to declare a template?
Read More Section(C plus plus miscellaneous)
Each Section contains maximum 100 MCQs question on C plus plus miscellaneous. To get more questions visit other sections.
- C plus plus miscellaneous - Section 1
- C plus plus miscellaneous - Section 2
- C plus plus miscellaneous - Section 3
- C plus plus miscellaneous - Section 4
- C plus plus miscellaneous - Section 5
- C plus plus miscellaneous - Section 6
- C plus plus miscellaneous - Section 7
- C plus plus miscellaneous - Section 9
- C plus plus miscellaneous - Section 10
- C plus plus miscellaneous - Section 11
