31. Which of the following is an advantage of Forward iterator over input and output iterator?
32. What does derived class does not inherit from the base class?
33. In which type of semantics does c++ implements iterator?
34. Which operators are part of RTTI?
35. What will be the output of the following C++ code?
#include <iostream>
#include <vector>
using namespace std;
int main()
{
vector<int> v;
for (int i = 1; i <= 5; i++)
v.push_back(i);
cout<<v.capacity()<<endl;
v.pop_back();
v.pop_back();
cout<<v.capacity()<<endl;
return 0;
}
#include <iostream>
#include <vector>
using namespace std;
int main()
{
vector<int> v;
for (int i = 1; i <= 5; i++)
v.push_back(i);
cout<<v.capacity()<<endl;
v.pop_back();
v.pop_back();
cout<<v.capacity()<<endl;
return 0;
}36. Which is referred by pointers to member?
37. Which of the following Operator cannot be used with pairs?
38. How many types of Iterators are there?
39. What will be the output of the following C++ code?
#include <iostream>
#include <string>
#include <cstring>
using namespace std;
template <class type>
type MyMax(const type Var1, const type Var2)
{
cout << "no specialization";
return Var1 < Var2 ? Var2 : Var1;
}
template <>
const char *MyMax(const char *Var1, const char *Var2)
{
return (strcmp(Var1, Var2)<0) ? Var2 : Var1;
}
int main()
{
string Str1 = "class", Str2 = "template";
const char *Var3 = "class";
const char *Var4 = "template";
const char *q = MyMax(Var3, Var4);
cout << q << endl;
return 0;
}
#include <iostream>
#include <string>
#include <cstring>
using namespace std;
template <class type>
type MyMax(const type Var1, const type Var2)
{
cout << "no specialization";
return Var1 < Var2 ? Var2 : Var1;
}
template <>
const char *MyMax(const char *Var1, const char *Var2)
{
return (strcmp(Var1, Var2)<0) ? Var2 : Var1;
}
int main()
{
string Str1 = "class", Str2 = "template";
const char *Var3 = "class";
const char *Var4 = "template";
const char *q = MyMax(Var3, Var4);
cout << q << endl;
return 0;
}40. What will be the output of the following C++ code in text files?
#include <stdio.h>
int main ()
{
char buffer[BUFSIZ];
FILE *p1, *p2;
p1 = fopen ("myfile.txt", "w");
p2 = fopen ("myfile2.txt", "a");
setbuf ( p1 , buffer );
fputs ("Buffered stream", p1);
fflush (p1);
setbuf ( p2 , NULL );
fputs ("Unbuffered stream", p2);
fclose (p1);
fclose (p2);
return 0;
}
#include <stdio.h>
int main ()
{
char buffer[BUFSIZ];
FILE *p1, *p2;
p1 = fopen ("myfile.txt", "w");
p2 = fopen ("myfile2.txt", "a");
setbuf ( p1 , buffer );
fputs ("Buffered stream", p1);
fflush (p1);
setbuf ( p2 , NULL );
fputs ("Unbuffered stream", p2);
fclose (p1);
fclose (p2);
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
