61. What will be the output of the following C++ code?
#include <iostream>
using namespace std;
template <class T, int N>
class mysequence
{
T memblock [N];
public:
void setmember (int x, T value);
T getmember (int x);
};
template <class T, int N>
void mysequence<T,N> :: setmember (int x, T value)
{
memblock[x] = value;
}
template <class T, int N>
T mysequence<T,N> :: getmember (int x)
{
return memblock[x];
}
int main ()
{
mysequence <int, 5> myints;
mysequence <double, 5> myfloats;
myints.setmember (0, 100);
myfloats.setmember (3, 3.1416);
cout << myints.getmember(0) << '\n';
cout << myfloats.getmember(3) << '\n';
return 0;
}
#include <iostream>
using namespace std;
template <class T, int N>
class mysequence
{
T memblock [N];
public:
void setmember (int x, T value);
T getmember (int x);
};
template <class T, int N>
void mysequence<T,N> :: setmember (int x, T value)
{
memblock[x] = value;
}
template <class T, int N>
T mysequence<T,N> :: getmember (int x)
{
return memblock[x];
}
int main ()
{
mysequence <int, 5> myints;
mysequence <double, 5> myfloats;
myints.setmember (0, 100);
myfloats.setmember (3, 3.1416);
cout << myints.getmember(0) << '\n';
cout << myfloats.getmember(3) << '\n';
return 0;
}62. What are the vectors?
63. By using which of the following the elements in the associate container can be efficiently accessed?
64. What is the use of middle parameter in the rotate method?
65. What is the output of this C++ program in the "test.txt" file?
#include <fstream>
using namespace std;
int main ()
{
long pos;
ofstream outfile;
outfile.open ("test.txt");
outfile.write ("This is an apple",16);
pos = outfile.tellp();
outfile.seekp (pos - 7);
outfile.write (" sam", 4);
outfile.close();
return 0;
}
#include <fstream>
using namespace std;
int main ()
{
long pos;
ofstream outfile;
outfile.open ("test.txt");
outfile.write ("This is an apple",16);
pos = outfile.tellp();
outfile.seekp (pos - 7);
outfile.write (" sam", 4);
outfile.close();
return 0;
}66. Which of the following is correct about remove_extent() function?
67. What will be the output of the following C++ code?
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
int main ()
{
int myints[]={ 10, 20, 30, 40, 50 };
vector<int> myvector (4, 99);
iter_swap(myints, myvector.begin());
iter_swap(myints + 3,myvector.begin() + 2);
for (vector<int> :: iterator it = myvector.begin();
it != myvector.end(); ++it)
cout << ' ' << *it;
return 0;
}
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
int main ()
{
int myints[]={ 10, 20, 30, 40, 50 };
vector<int> myvector (4, 99);
iter_swap(myints, myvector.begin());
iter_swap(myints + 3,myvector.begin() + 2);
for (vector<int> :: iterator it = myvector.begin();
it != myvector.end(); ++it)
cout << ' ' << *it;
return 0;
}68. What happens when no argument is supplied to set() function?
69. Which character is used to separate different arguments?
70. What is the use of polar function?
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
