51. What do associate containers implement?
52. vptr is . . . . . . . .
53. What is linear_congruential_engine?
54. What will be the output of the following C++ code?
#include <iostream>
using namespace std;
struct A
{
private:
int i, j, k;
public:
int f();
void g();
};
int A :: f()
{
return i + j + k;
}
void A :: g()
{
i = j = k = 0;
}
class B
{
int i, j, k;
public:
int f();
void g();
};
int B :: f()
{
return i + j + k;
}
void B :: g()
{
i = j = k = 0;
}
int main()
{
A a;
B b;
a.f();
a.g();
b.f();
b.g();
cout << "Identical results would be produced";
}
#include <iostream>
using namespace std;
struct A
{
private:
int i, j, k;
public:
int f();
void g();
};
int A :: f()
{
return i + j + k;
}
void A :: g()
{
i = j = k = 0;
}
class B
{
int i, j, k;
public:
int f();
void g();
};
int B :: f()
{
return i + j + k;
}
void B :: g()
{
i = j = k = 0;
}
int main()
{
A a;
B b;
a.f();
a.g();
b.f();
b.g();
cout << "Identical results would be produced";
}55. Which container is best to keep the collection of distinct elements?
56. What will be the output of the following C++ code?
#include <iostream>
#include <cmath>
#include <list>
using namespace std;
bool same_integral_part (double first, double second)
{
return ( int(first) == int(second) );
}
struct is_near
{
bool operator() (double first, double second)
{
return (fabs(first - second) < 5.0);
}
};
int main ()
{
double mydoubles[] = { 12.15, 2.72, 73.0, 12.77, 3.14, 12.77, 73.35, 72.25, 15.3, 72.25 };
list<double> mylist (mydoubles, mydoubles + 10);
mylist.sort();
mylist.unique();
mylist.unique (same_integral_part);
mylist.unique (is_near());
for (list<double> :: iterator it = mylist.begin(); it != mylist.end(); ++it)
cout << ' ' << *it;
cout << '\n';
return 0;
}
#include <iostream>
#include <cmath>
#include <list>
using namespace std;
bool same_integral_part (double first, double second)
{
return ( int(first) == int(second) );
}
struct is_near
{
bool operator() (double first, double second)
{
return (fabs(first - second) < 5.0);
}
};
int main ()
{
double mydoubles[] = { 12.15, 2.72, 73.0, 12.77, 3.14, 12.77, 73.35, 72.25, 15.3, 72.25 };
list<double> mylist (mydoubles, mydoubles + 10);
mylist.sort();
mylist.unique();
mylist.unique (same_integral_part);
mylist.unique (is_near());
for (list<double> :: iterator it = mylist.begin(); it != mylist.end(); ++it)
cout << ' ' << *it;
cout << '\n';
return 0;
}57. What do you mean by "No exception specification"?
58. What is a pair?
59. What will be the output of the following C++ code?
#include<iostream>
#include<any>
using namespace std;
int main()
{
float val = 5.5;
any var(val);
cout<<any_cast<float>(var)<<endl;
var.reset();
if(!var.has_value())
{
cout<<"var is empty\n";
}
else{
cout<<"var is not empty\n";
}
return 0;
}
#include<iostream>
#include<any>
using namespace std;
int main()
{
float val = 5.5;
any var(val);
cout<<any_cast<float>(var)<<endl;
var.reset();
if(!var.has_value())
{
cout<<"var is empty\n";
}
else{
cout<<"var is not empty\n";
}
return 0;
}60. Which operations don't throw anything?
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 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 8
- C plus plus miscellaneous - Section 9
- C plus plus miscellaneous - Section 10
- C plus plus miscellaneous - Section 11
