41. What will be the output of the following C++ code?
#include <iostream>
using namespace std;
template<typename type>
class Test
{
public:
Test()
{
};
~Test()
{
};
type Funct1(type Var1)
{
return Var1;
}
type Funct2(type Var2)
{
return Var2;
}
};
int main()
{
Test<int> Var1;
Test<float> Var2;
cout << Var1.Funct1(200) << endl;
cout << Var2.Funct2(3.123) << endl;
return 0;
}
#include <iostream>
using namespace std;
template<typename type>
class Test
{
public:
Test()
{
};
~Test()
{
};
type Funct1(type Var1)
{
return Var1;
}
type Funct2(type Var2)
{
return Var2;
}
};
int main()
{
Test<int> Var1;
Test<float> Var2;
cout << Var1.Funct1(200) << endl;
cout << Var2.Funct2(3.123) << endl;
return 0;
}42. What will be the output of the following C++ code?
#include <iostream>
#include <functional>
#include <algorithm>
using namespace std;
int main ()
{
int first[] = {10, 40, 90};
int second[] = {1, 2, 3};
int results[5];
transform ( first, first + 5, second, results, divides<int>());
for (int i = 0; i < 3; i++)
cout << results[i] << " ";
return 0;
}
#include <iostream>
#include <functional>
#include <algorithm>
using namespace std;
int main ()
{
int first[] = {10, 40, 90};
int second[] = {1, 2, 3};
int results[5];
transform ( first, first + 5, second, results, divides<int>());
for (int i = 0; i < 3; i++)
cout << results[i] << " ";
return 0;
}43. What will be the output of the following C++ code?
#include <iostream>
#include <bitset>
using namespace std;
int main()
{
bitset<8> b1(20);
cout<<b1.none();
cout<<b1.any();
}
#include <iostream>
#include <bitset>
using namespace std;
int main()
{
bitset<8> b1(20);
cout<<b1.none();
cout<<b1.any();
}44. Which interface in the container is required for storage management?
45. What will be the output of the following C++ code?
#include <iostream>
using namespace std;
void PrintSequence(int StopNum)
{
int Num;
Num = 1;
while (true)
{
if (Num >= StopNum)
throw Num;
cout << Num << endl;
Num++;
}
}
int main(void)
{
try
{
PrintSequence(2);
}
catch(int ExNum)
{
cout << "exception: " << ExNum << endl;
}
return 0;
}
#include <iostream>
using namespace std;
void PrintSequence(int StopNum)
{
int Num;
Num = 1;
while (true)
{
if (Num >= StopNum)
throw Num;
cout << Num << endl;
Num++;
}
}
int main(void)
{
try
{
PrintSequence(2);
}
catch(int ExNum)
{
cout << "exception: " << ExNum << endl;
}
return 0;
}46. What will happen when introduce the interface of classes in a run-time polymorphic hierarchy?
47. What will be the output of the following C++ code?
#include <iostream>
using namespace std;
class BaseClass
{
int i;
public:
void setInt(int n);
int getInt();
};
class DerivedClass : public BaseClass
{
int j;
public:
void setJ(int n);
int mul();
};
void BaseClass::setInt(int n)
{
i = n;
}
int BaseClass::getInt()
{
return i;
}
void DerivedClass::setJ(int n)
{
j = n;
}
int DerivedClass::mul()
{
return j * getInt();
}
int main()
{
DerivedClass ob;
ob.setInt(10);
ob.setJ(4);
cout << ob.mul();
return 0;
}
#include <iostream>
using namespace std;
class BaseClass
{
int i;
public:
void setInt(int n);
int getInt();
};
class DerivedClass : public BaseClass
{
int j;
public:
void setJ(int n);
int mul();
};
void BaseClass::setInt(int n)
{
i = n;
}
int BaseClass::getInt()
{
return i;
}
void DerivedClass::setJ(int n)
{
j = n;
}
int DerivedClass::mul()
{
return j * getInt();
}
int main()
{
DerivedClass ob;
ob.setInt(10);
ob.setJ(4);
cout << ob.mul();
return 0;
}48. How many types are there in binary heaps?
49. Which function is invoked when we try to throw an exception that is not supported by a function?
50. What is the use of vector arithmetic in c++?
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 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
