21. What will be the output of the following C++ code?
#include <iostream>
using namespace std;
template <typename T, typename U>
void squareAndPrint(T x, U y)
{
cout << x << x * x << endl;
cout << y << " " << y * y << endl;
};
int main()
{
int ii = 2;
float jj = 2.1;
squareAndPrint<int, float>(ii, jj);
}
#include <iostream>
using namespace std;
template <typename T, typename U>
void squareAndPrint(T x, U y)
{
cout << x << x * x << endl;
cout << y << " " << y * y << endl;
};
int main()
{
int ii = 2;
float jj = 2.1;
squareAndPrint<int, float>(ii, jj);
}
22. Which of the following is a Non-modifying Sequence Operation?
23. What will be the output of the following C++ code?
#include <iostream>
#include <list>
using namespace std;
int main ()
{
list<int> mylist;
list<int> :: iterator it1, it2;
for (int i = 1; i < 10; ++i) mylist.push_back(i * 1);
it1 = it2 = mylist.begin();
advance (it2, 6);
++it1;
it1 = mylist.erase (it1);
it2 = mylist.erase (it2);
++it1;
--it2;
mylist.erase (it1, it2);
for (it1 = mylist.begin(); it1 != mylist.end(); ++it1)
cout << ' ' << *it1;
return 0;
}
#include <iostream>
#include <list>
using namespace std;
int main ()
{
list<int> mylist;
list<int> :: iterator it1, it2;
for (int i = 1; i < 10; ++i) mylist.push_back(i * 1);
it1 = it2 = mylist.begin();
advance (it2, 6);
++it1;
it1 = mylist.erase (it1);
it2 = mylist.erase (it2);
++it1;
--it2;
mylist.erase (it1, it2);
for (it1 = mylist.begin(); it1 != mylist.end(); ++it1)
cout << ' ' << *it1;
return 0;
}
24. What is the use of is_same() function in C++?
25. What will be the output of the following C++ code?
#include <iostream>
using namespace std;
class Base
{
public:
Base(){}
~Base(){}
protected:
private:
};
class Derived:public Base
{
public:
Derived(){}
Derived(){}
private:
protected:
};
int main()
{
cout << "The program exceuted" << endl;
}
#include <iostream>
using namespace std;
class Base
{
public:
Base(){}
~Base(){}
protected:
private:
};
class Derived:public Base
{
public:
Derived(){}
Derived(){}
private:
protected:
};
int main()
{
cout << "The program exceuted" << endl;
}
26. What type of reference should be used in vector arithmetic?
27. What will be the output of the following C++ code?
#include <iostream>
#include <algorithm>
using namespace std;
int main ()
{
cout << min(2, 1) << ' ';
cout << min('m','m') << '\n';
return 0;
}
#include <iostream>
#include <algorithm>
using namespace std;
int main ()
{
cout << min(2, 1) << ' ';
cout << min('m','m') << '\n';
return 0;
}
28. Which value is pointed out first in heap?
29. What will be the output of the following C++ code?
#include <iostream>
#include<type_traits>
using namespace std;
class Base
{
public:
void function1() {};
void function2() {};
};
int main()
{
Base b;
cout<<sizeof(b);
return 0;
}
#include <iostream>
#include<type_traits>
using namespace std;
class Base
{
public:
void function1() {};
void function2() {};
};
int main()
{
Base b;
cout<<sizeof(b);
return 0;
}
30. Which of the following(s) is/are the correct way of assigning values to a forward_list f?
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 8
- C plus plus miscellaneous - Section 9
- C plus plus miscellaneous - Section 10
- C plus plus miscellaneous - Section 11