91. Which of the following is a logical unary functor?
92. What is the use of front() function in heap?
93. In how many ways we can capture the external variables in the lambda expression?
94. What will be the output of the following C++ code?
#include <iostream>
using namespace std;
class Testpm
{
public:
void m_func1()
{
cout << "func1\n";
}
int m_num;
};
void (Testpm :: *pmfn)() = &Testpm :: m_func1;
int Testpm :: *pmd = &Testpm :: m_num;
int main()
{
Testpm ATestpm;
Testpm *pTestpm = new Testpm;
(ATestpm.*pmfn)();
(pTestpm ->* pmfn)();
ATestpm.*pmd = 1;
pTestpm ->* pmd = 2;
cout << ATestpm.*pmd << endl
<< pTestpm ->* pmd << endl;
}
#include <iostream>
using namespace std;
class Testpm
{
public:
void m_func1()
{
cout << "func1\n";
}
int m_num;
};
void (Testpm :: *pmfn)() = &Testpm :: m_func1;
int Testpm :: *pmd = &Testpm :: m_num;
int main()
{
Testpm ATestpm;
Testpm *pTestpm = new Testpm;
(ATestpm.*pmfn)();
(pTestpm ->* pmfn)();
ATestpm.*pmd = 1;
pTestpm ->* pmd = 2;
cout << ATestpm.*pmd << endl
<< pTestpm ->* pmd << endl;
}95. What is lambda expression in C++?
96. What will be the output of the following C++ code?
#include <iostream>
#include <algorithm>
using namespace std;
bool myfn(int i, int j)
{
return i < j;
}
int main ()
{
int myints[ ] = {3, 7, 2, 5, 6, 4, 9};
cout << *min_element(myints, myints + 7, myfn) << '\n';
cout << *max_element(myints, myints + 7, myfn) << '\n';
return 0;
}
#include <iostream>
#include <algorithm>
using namespace std;
bool myfn(int i, int j)
{
return i < j;
}
int main ()
{
int myints[ ] = {3, 7, 2, 5, 6, 4, 9};
cout << *min_element(myints, myints + 7, myfn) << '\n';
cout << *max_element(myints, myints + 7, myfn) << '\n';
return 0;
}97. What is the syntax of swap()?
98. What will be the output of the following C++ code?
#include <iostream>
#include <complex>
using namespace std;
int main()
{
complex <double> cn(3.0, 4.0);
cout<<"proj"<<cn<<" : "<<proj(cn)<<endl;
return 0;
}
#include <iostream>
#include <complex>
using namespace std;
int main()
{
complex <double> cn(3.0, 4.0);
cout<<"proj"<<cn<<" : "<<proj(cn)<<endl;
return 0;
}99. What will be the output of the following C++ code?
#include<iostream>
using namespace std;
int main()
{
int a = 5;
auto check = [&]()
{
a = 10;
};
check();
cout<<"Value of a: "<<a<<endl;
return 0;
}
#include<iostream>
using namespace std;
int main()
{
int a = 5;
auto check = [&]()
{
a = 10;
};
check();
cout<<"Value of a: "<<a<<endl;
return 0;
}100. What will be the output of the following C++ code?
#include <iostream>
#include <deque>
using namespace std;
int main ()
{
deque<int> mydeque (5);
deque<int>::reverse_iterator rit = mydeque.rbegin();
int i = 0;
for (rit = mydeque.rbegin(); rit!= mydeque.rend(); ++rit)
*rit = ++i;
for (deque<int> :: iterator it = mydeque.begin();
it != mydeque.end(); ++it)
cout << ' ' << *it;
return 0;
}
#include <iostream>
#include <deque>
using namespace std;
int main ()
{
deque<int> mydeque (5);
deque<int>::reverse_iterator rit = mydeque.rbegin();
int i = 0;
for (rit = mydeque.rbegin(); rit!= mydeque.rend(); ++rit)
*rit = ++i;
for (deque<int> :: iterator it = mydeque.begin();
it != mydeque.end(); ++it)
cout << ' ' << *it;
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 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
