91. What will be the output of the following C++ code?
#include <iostream>
#include <string>
#include <cstdlib>
using namespace std;
template<class T>
T func(T a)
{
return a;
}
template<class T, class U>
T func(U a)
{
return (T)a;
}
int main(int argc, char const *argv[])
{
int a = 5;
int b = func(a);
int c = func(5.5);
cout<<b<<c<<endl;
return 0;
}
#include <iostream>
#include <string>
#include <cstdlib>
using namespace std;
template<class T>
T func(T a)
{
return a;
}
template<class T, class U>
T func(U a)
{
return (T)a;
}
int main(int argc, char const *argv[])
{
int a = 5;
int b = func(a);
int c = func(5.5);
cout<<b<<c<<endl;
return 0;
}92. Which of the following statements are correct about Catch handler?
i. It must be placed immediately after the try block
ii. It can have more than one parameters
iii. There must be one and only one catch handler for every try block
iv. There can be multiple catch handler for a try block
v. General catch handler can be kept anywhere after try block.
i. It must be placed immediately after the try block
ii. It can have more than one parameters
iii. There must be one and only one catch handler for every try block
iv. There can be multiple catch handler for a try block
v. General catch handler can be kept anywhere after try block.
93. What is the class relationship?
94. What will be the output of the following C++ code?
#include <iostream>
using namespace std;
template <class type>
class Test
{
public:
Test();
~Test();
type Data(type);
};
template <class type>
type Test<type>::Data(type Var0)
{
return Var0;
}
template <class type>
Test<type>::Test()
{
}
template <class type>
Test<type>::~Test()
{
}
int main(void)
{
Test<char> Var3;
cout << Var3.Data('K') << endl;
return 0;
}
#include <iostream>
using namespace std;
template <class type>
class Test
{
public:
Test();
~Test();
type Data(type);
};
template <class type>
type Test<type>::Data(type Var0)
{
return Var0;
}
template <class type>
Test<type>::Test()
{
}
template <class type>
Test<type>::~Test()
{
}
int main(void)
{
Test<char> Var3;
cout << Var3.Data('K') << endl;
return 0;
}95. What will be the output of the following C++ code?
#include <iostream>
#include <iterator>
#include <vector>
using namespace std;
int main ()
{
vector<int> myvector;
for (int i = 0; i < 10; i++)
myvector.push_back(i);
typedef vector<int> :: iterator iter_int;
reverse_iterator<iter_int> rev_iterator;
rev_iterator = myvector.rend() - 4;
cout << *rev_iterator << endl;
return 0;
}
#include <iostream>
#include <iterator>
#include <vector>
using namespace std;
int main ()
{
vector<int> myvector;
for (int i = 0; i < 10; i++)
myvector.push_back(i);
typedef vector<int> :: iterator iter_int;
reverse_iterator<iter_int> rev_iterator;
rev_iterator = myvector.rend() - 4;
cout << *rev_iterator << endl;
return 0;
}96. What will be the output of the following C++ code?
#include <iostream>
using namespace std;
int main()
{
unsigned long x = 64;
cout << x << oct << x << endl;
return 0;
}
#include <iostream>
using namespace std;
int main()
{
unsigned long x = 64;
cout << x << oct << x << endl;
return 0;
}97. What will be the output of the following C++ code?
#include <iostream>
using namespace std;
int main()
{
int x = -1;
try
{
if (x < 0)
{
throw x;
}
else
{
cout<<x;
}
}
catch (int x )
{
cout << "Exception occurred: Thrown value is " << x << endl;
}
return 0;
}
#include <iostream>
using namespace std;
int main()
{
int x = -1;
try
{
if (x < 0)
{
throw x;
}
else
{
cout<<x;
}
}
catch (int x )
{
cout << "Exception occurred: Thrown value is " << x << endl;
}
return 0;
}98. What is the difference between get() and at()?
99. How the different permutations are ordered in c++?
100. What is the use of accumulate function in a numeric library?
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 8
- C plus plus miscellaneous - Section 9
- C plus plus miscellaneous - Section 11
