1. What kind of errors do checked iterators detect?
2. Pick out the correct statement.
3. What will the monetary facet will do?
4. What will be the output of the following C++ code?
#include <iostream>
#include <string>
#include <cstdlib>
using namespace std;
template<class T, class U = char>
class A
{
T a;
U b;
public:
A(T a_val, char b_val = '$'){
this->a = a_val;
this->b = b_val;
}
void print(){
cout<<a<<' '<<b<<endl;
}
};
int main(int argc, char const *argv[])
{
A <int, int> a1(5,10);
A <int> a2(5);
A <float> a3(10.0);
return 0;
}
#include <iostream>
#include <string>
#include <cstdlib>
using namespace std;
template<class T, class U = char>
class A
{
T a;
U b;
public:
A(T a_val, char b_val = '$'){
this->a = a_val;
this->b = b_val;
}
void print(){
cout<<a<<' '<<b<<endl;
}
};
int main(int argc, char const *argv[])
{
A <int, int> a1(5,10);
A <int> a2(5);
A <float> a3(10.0);
return 0;
}
5. Which is used for manually writing lookup table?
6. Which function is used to swap two Valarray?
7. 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);
if(var.has_value())
{
cout<<"Var is not Empty\n";
}
else
{
cout<<"Var is Empty\n";
}
return 0;
}
#include<iostream>
#include<any>
using namespace std;
int main()
{
float val = 5.5;
any var(val);
if(var.has_value())
{
cout<<"Var is not Empty\n";
}
else
{
cout<<"Var is Empty\n";
}
return 0;
}
8. What will be the output of the following C++ code?
#include<iostream>
using namespace std;
class Add
{
int x;
public:
Add(int x){
this->x = x;
}
int operator()(int a){
return x+a;
}
};
int main()
{
Add add_5(5);
int a = 5;
cout<<add_5(a);
return 0;
}
#include<iostream>
using namespace std;
class Add
{
int x;
public:
Add(int x){
this->x = x;
}
int operator()(int a){
return x+a;
}
};
int main()
{
Add add_5(5);
int a = 5;
cout<<add_5(a);
return 0;
}
9. What does inheritance allow you to do?
10. What will be the output of the following C++ code?
#include <iostream>
using namespace std;
int main(void)
{
const char *one = "Test";
cout << one << endl;
const char *two = one;
cout << two << endl;
return 0;
}
#include <iostream>
using namespace std;
int main(void)
{
const char *one = "Test";
cout << one << endl;
const char *two = one;
cout << two << endl;
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 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