91. How many items are presented in the associate container?
92. What will be the output of the following C++ code?
#include <iostream>
#include <memory>
#include <algorithm>
using namespace std;
int main ()
{
int numbers[] = {1, 5, 4, 5};
pair <int*, ptrdiff_t> result = get_temporary_buffer<int>(4);
if (result.second > 0)
{
uninitialized_copy (numbers, numbers + result.second, result.first);
sort (result.first, result.first + result.second);
for (int i = 0; i < result.second; i++)
cout << result.first[i] << " ";
return_temporary_buffer (result.first);
}
return 0;
}
#include <iostream>
#include <memory>
#include <algorithm>
using namespace std;
int main ()
{
int numbers[] = {1, 5, 4, 5};
pair <int*, ptrdiff_t> result = get_temporary_buffer<int>(4);
if (result.second > 0)
{
uninitialized_copy (numbers, numbers + result.second, result.first);
sort (result.first, result.first + result.second);
for (int i = 0; i < result.second; i++)
cout << result.first[i] << " ";
return_temporary_buffer (result.first);
}
return 0;
}93. Which constructor will initialize the base class data member?
94. What will be the output of the following C++ code?
#include <iostream>
using namespace std;
struct X;
struct Y
{
void f(X*);
};
struct X
{
private:
int i;
public:
void initialize();
friend void g(X* , int);
friend void Y :: f(X*);
friend struct Z;
friend void h();
};
void X :: initialize()
{
i = 0;
}
void g(X* x, int i)
{
x -> i = i;
}
void Y :: f(X * x)
{
x -> i = 47;
cout << x->i;
}
struct Z
{
private:
int j;
public:
void initialize();
void g(X* x);
};
void Z::initialize()
{
j = 99;
}
void Z::g(X* x)
{
x -> i += j;
}
void h()
{
X x;
x.i = 100;
cout << x.i;
}
int main()
{
X x;
Z z;
z.g(&x);
cout << "Data accessed";
}
#include <iostream>
using namespace std;
struct X;
struct Y
{
void f(X*);
};
struct X
{
private:
int i;
public:
void initialize();
friend void g(X* , int);
friend void Y :: f(X*);
friend struct Z;
friend void h();
};
void X :: initialize()
{
i = 0;
}
void g(X* x, int i)
{
x -> i = i;
}
void Y :: f(X * x)
{
x -> i = 47;
cout << x->i;
}
struct Z
{
private:
int j;
public:
void initialize();
void g(X* x);
};
void Z::initialize()
{
j = 99;
}
void Z::g(X* x)
{
x -> i += j;
}
void h()
{
X x;
x.i = 100;
cout << x.i;
}
int main()
{
X x;
Z z;
z.g(&x);
cout << "Data accessed";
}95. What will be the output of the following C++ code?
#include <iostream>
#include <vector>
using namespace std;
int main ()
{
unsigned int i;
vector<int> first;
vector<int> second (4, 100);
vector<int> third (second.begin(), second.end());
vector<int> fourth (third);
int myints[] = {16, 2, 77, 29};
vector<int> fifth (myints, myints + sizeof(myints) / sizeof(int) );
for (vector<int> :: iterator it = fifth.begin(); it != fifth.end(); ++it)
cout << ' ' << *it;
return 0;
}
#include <iostream>
#include <vector>
using namespace std;
int main ()
{
unsigned int i;
vector<int> first;
vector<int> second (4, 100);
vector<int> third (second.begin(), second.end());
vector<int> fourth (third);
int myints[] = {16, 2, 77, 29};
vector<int> fifth (myints, myints + sizeof(myints) / sizeof(int) );
for (vector<int> :: iterator it = fifth.begin(); it != fifth.end(); ++it)
cout << ' ' << *it;
return 0;
}96. What does size() function returns?
97. What will be the output of the following C++ code?
#include<iostream>
#include<iterator>
#include<vector>
using namespace std;
int main()
{
vector<int> ar = { 1, 2, 3, 4, 5 };
vector<int>::iterator ptr = ar.begin();
advance(ptr, 2);
cout << *ptr << endl;
return 0;
}
#include<iostream>
#include<iterator>
#include<vector>
using namespace std;
int main()
{
vector<int> ar = { 1, 2, 3, 4, 5 };
vector<int>::iterator ptr = ar.begin();
advance(ptr, 2);
cout << *ptr << endl;
return 0;
}98. Which of the following is correct?
99. When exceptions are used?
100. Which of te following is a built-in example of functors 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 3
- 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
