41. What is the use of empty() function in array classes?
42. How many groups of output of operation are there in c++?
43. What kind of error can arise when there is a problem with memory?
44. What will be the output of the following C++ code?
#include <iostream>
#include <map>
using namespace std;
int main ()
{
try {
map<char, int> mymap;
map<char, int> :: iterator it;
mymap['a'] = 50;
mymap['b'] = 100;
mymap['c'] = 150;
mymap['d'] = 200;
it = mymap.find('b');
mymap.erase (it);
mymap.erase (mymap.find('d'));
cout << mymap.find('a') -> second << '\n';
}
catch (...)
{
cout << "Unknown exception: " << endl;
}
return 0;
}
#include <iostream>
#include <map>
using namespace std;
int main ()
{
try {
map<char, int> mymap;
map<char, int> :: iterator it;
mymap['a'] = 50;
mymap['b'] = 100;
mymap['c'] = 150;
mymap['d'] = 200;
it = mymap.find('b');
mymap.erase (it);
mymap.erase (mymap.find('d'));
cout << mymap.find('a') -> second << '\n';
}
catch (...)
{
cout << "Unknown exception: " << endl;
}
return 0;
}45. What will be the output of the following C++ code?
#include <iostream>
using namespace std;
class BaseClass
{
public:
virtual void myFunction()
{
cout << "1";
}
};
class DerivedClass1 : public BaseClass
{
public:
void myFunction()
{
cout << "2";
}
};
class DerivedClass2 : public DerivedClass1
{
public:
void myFunction()
{
cout << "3";
}
};
int main()
{
BaseClass *p;
BaseClass ob;
DerivedClass1 derivedObject1;
DerivedClass2 derivedObject2;
p = &ob;
p -> myFunction();
p = &derivedObject1;
p -> myFunction();
p = &derivedObject2;
p -> myFunction();
return 0;
}
#include <iostream>
using namespace std;
class BaseClass
{
public:
virtual void myFunction()
{
cout << "1";
}
};
class DerivedClass1 : public BaseClass
{
public:
void myFunction()
{
cout << "2";
}
};
class DerivedClass2 : public DerivedClass1
{
public:
void myFunction()
{
cout << "3";
}
};
int main()
{
BaseClass *p;
BaseClass ob;
DerivedClass1 derivedObject1;
DerivedClass2 derivedObject2;
p = &ob;
p -> myFunction();
p = &derivedObject1;
p -> myFunction();
p = &derivedObject2;
p -> myFunction();
return 0;
}46. What will be the output of the following C++ code?
#include <iostream>
#include <cctype>
using namespace std;
int main(int argc, char const *argv[])
{
char arr[12] = "H3ll0\tW0r1d";
for(int i=0;i<12;i++)
{
cout<<(bool)isprint(arr[i]);
}
}
#include <iostream>
#include <cctype>
using namespace std;
int main(int argc, char const *argv[])
{
char arr[12] = "H3ll0\tW0r1d";
for(int i=0;i<12;i++)
{
cout<<(bool)isprint(arr[i]);
}
}47. Which of the following class template are based on arrays?
48. What must be specified when we construct an object of class ostream?
49. What is the correct syntax of constructing any using copy initialization?
50. 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.test(1);
cout<<b1.test(2);
}
#include <iostream>
#include <bitset>
using namespace std;
int main()
{
bitset<8> b1(20);
cout<<b1.test(1);
cout<<b1.test(2);
}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
