41. What is the purpose of the 'std::forward_list' container in C++ STL?
42. Which algorithm in C++ STL is used to sort a range of elements using quicksort?
43. What is the purpose of the 'std::array' container in C++ STL?
44. Which algorithm in C++ STL is used to compute the sum of elements in a range?
45. What will be the output of the following C++ code?
#include <stdio.h>
#include <math.h>
int main ()
{
printf ("%lf\n", fmod (5.3, 2) );
printf ("%lf\n", fmod (18.5, 4.2) );
return 0;
}
#include <stdio.h>
#include <math.h>
int main ()
{
printf ("%lf\n", fmod (5.3, 2) );
printf ("%lf\n", fmod (18.5, 4.2) );
return 0;
}
46. What will be the output of the following C++ code?
#include <typeinfo>
#include <iostream>
using namespace std;
class shape
{
public:
virtual void myvirtualfunc() const {}
};
class mytriangle: public shape
{
public:
virtual void myvirtualfunc() const
{
};
};
int main()
{
shape shape_instance;
shape &ref_shape = shape_instance;
try
{
mytriangle &ref_mytriangle = dynamic_cast(ref_shape);
}
catch (bad_cast)
{
cout << "Caught: bad_cast exception\n";
}
return 0;
}
#include <typeinfo>
#include <iostream>
using namespace std;
class shape
{
public:
virtual void myvirtualfunc() const {}
};
class mytriangle: public shape
{
public:
virtual void myvirtualfunc() const
{
};
};
int main()
{
shape shape_instance;
shape &ref_shape = shape_instance;
try
{
mytriangle &ref_mytriangle = dynamic_cast(ref_shape);
}
catch (bad_cast)
{
cout << "Caught: bad_cast exception\n";
}
return 0;
}
47. Which is best for coding the standard library for c++?
48. Where are standard exception classes grouped?
49. What will be the output of the following C++ code?
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
int main ()
{
vector<int> myvector;
for (int i = 1; i < 6; ++i)
myvector.push_back(i);
reverse(myvector.begin(), myvector.end());
for (vector<int> :: iterator it = myvector.begin(); it != myvector.end(); ++it)
cout << ' ' << *it;
return 0;
}
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
int main ()
{
vector<int> myvector;
for (int i = 1; i < 6; ++i)
myvector.push_back(i);
reverse(myvector.begin(), myvector.end());
for (vector<int> :: iterator it = myvector.begin(); it != myvector.end(); ++it)
cout << ' ' << *it;
return 0;
}
50. How many parameters are used in frexp function?
Read More Section(Standard Template Library (STL) in C plus plus)
Each Section contains maximum 100 MCQs question on Standard Template Library (STL) in C plus plus. To get more questions visit other sections.