31. Which of the things does not require instantiation?
32. What will be the output of the following C++ code?
#include <iostream>
#include <string>
#include <sstream>
using namespace std;
int main ()
{
string mystr;
float price = 0;
int quantity = 0;
cout << "Enter price: ";
getline (cin, mystr);
stringstream(mystr) >> price;
cout << "Enter quantity: ";
getline (cin, mystr);
stringstream(mystr) >> quantity;
cout << "Total price: " << price * quantity << endl;
return 0;
}
#include <iostream>
#include <string>
#include <sstream>
using namespace std;
int main ()
{
string mystr;
float price = 0;
int quantity = 0;
cout << "Enter price: ";
getline (cin, mystr);
stringstream(mystr) >> price;
cout << "Enter quantity: ";
getline (cin, mystr);
stringstream(mystr) >> quantity;
cout << "Total price: " << price * quantity << endl;
return 0;
}
33. Which of the following can derived class inherit?
34. Which interface determines how your class will be used by another program?
35. What is the use of the function "showbase"?
36. How many runtime error messages associated with exception?
37. What will be the output of the following C++ code?
#include <iostream>
using namespace std;
int main()
{
try
{
try
{
throw 20;
}
catch (int n)
{
cout << "Inner Catch\n";
}
}
catch (int x)
{
cout << "Outer Catch\n";
}
return 0;
}
#include <iostream>
using namespace std;
int main()
{
try
{
try
{
throw 20;
}
catch (int n)
{
cout << "Inner Catch\n";
}
}
catch (int x)
{
cout << "Outer Catch\n";
}
return 0;
}
38. What will be the output of the following C++ code?
#include <iostream>
#include <vector>
using namespace std;
int main ()
{
vector<int> a (3, 0);
vector<int> b (5, 0);
b = a;
a = vector<int>();
cout << "Size of a " << int(a.size()) << '\n';
cout << "Size of b " << int(b.size()) << '\n';
return 0;
}
#include <iostream>
#include <vector>
using namespace std;
int main ()
{
vector<int> a (3, 0);
vector<int> b (5, 0);
b = a;
a = vector<int>();
cout << "Size of a " << int(a.size()) << '\n';
cout << "Size of b " << int(b.size()) << '\n';
return 0;
}
39. What will be the output of the following C++ code?
#include <iostream>
using namespace std;
template <typename T>
void fun(const T&x)
{
static int count = 0;
cout << "x = " << x << " count = " << count;
++count;
return;
}
int main()
{
fun<int> (1);
cout << endl;
fun<int>(1);
cout << endl;
fun<double>(1.1);
cout << endl;
return 0;
}
#include <iostream>
using namespace std;
template <typename T>
void fun(const T&x)
{
static int count = 0;
cout << "x = " << x << " count = " << count;
++count;
return;
}
int main()
{
fun<int> (1);
cout << endl;
fun<int>(1);
cout << endl;
fun<double>(1.1);
cout << endl;
return 0;
}
40. Which of the following is the correct syntax of accessing the first element of a pair p?
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