51. Which parameter is legal for non-type template?
52. Which of the following is used for generic programming?
53. What will be the output of the following C++ code?
#include <iostream>
#include <vector>
using namespace std;
int main()
{
vector<int> v;
for (int i = 1; i <= 5; i++)
v.push_back(i);
cout<<v.capacity()<<endl;
v.resize(4);
cout<<v.capacity()<<endl;
return 0;
}
#include <iostream>
#include <vector>
using namespace std;
int main()
{
vector<int> v;
for (int i = 1; i <= 5; i++)
v.push_back(i);
cout<<v.capacity()<<endl;
v.resize(4);
cout<<v.capacity()<<endl;
return 0;
}54. What will be the output of the following C++ code?
#include <iostream>
#include<type_traits>
using namespace std;
class Base
{
public:
virtual void function1() {};
virtual void function2() {};
};
int main()
{
Base b;
cout<<sizeof(b);
return 0;
}
#include <iostream>
#include<type_traits>
using namespace std;
class Base
{
public:
virtual void function1() {};
virtual void function2() {};
};
int main()
{
Base b;
cout<<sizeof(b);
return 0;
}55. To which type of class, We can apply RTTI?
56. In how many ways templates concept can be used?
57. The if..else statement can be replaced by which operator?
58. What will be the output of the following C++ code?
#include <iostream>
using namespace std;
int main()
{
try
{
throw 1;
}
catch (int a)
{
cout << "exception number: " << a << endl;
return 0;
}
cout << "No exception " << endl;
return 0;
}
#include <iostream>
using namespace std;
int main()
{
try
{
throw 1;
}
catch (int a)
{
cout << "exception number: " << a << endl;
return 0;
}
cout << "No exception " << endl;
return 0;
}59. Which function is used to check whether a given sequence is heap or not?
60. What will be the output of the following C++ code?
#include <iostream>
#include <exception>
using namespace std;
class myexception: public exception
{
virtual const char* what() const throw()
{
return "exception arised";
}
} myex;
int main ()
{
try
{
throw myex;
}
catch (exception& e)
{
cout << e.what() << endl;
}
return 0;
}
#include <iostream>
#include <exception>
using namespace std;
class myexception: public exception
{
virtual const char* what() const throw()
{
return "exception arised";
}
} myex;
int main ()
{
try
{
throw myex;
}
catch (exception& e)
{
cout << e.what() << endl;
}
return 0;
}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 4
- C plus plus miscellaneous - Section 5
- C plus plus miscellaneous - Section 6
- C plus plus miscellaneous - Section 7
- C plus plus miscellaneous - Section 8
- C plus plus miscellaneous - Section 9
- C plus plus miscellaneous - Section 10
- C plus plus miscellaneous - Section 11
