51. What type of comments does c++ support?
52. What do vectors represent?
53. What will be the output of the following C++ code?
#include <iostream>
#include <algorithm>
#include <vector>
#include <functional>
using namespace std;
int op_increase (int i)
{
return ++i;
}
int main ()
{
vector<int> a;
vector<int> b;
for (int i = 1; i < 4; i++)
a.push_back (i * 10);
b.resize(a.size());
transform (a.begin(), a.end(), b.begin(), op_increase);
transform (a.begin(), a.end(), b.begin(), a.begin(), plus<int>());
for (vector<int> :: iterator it = a.begin(); it != a.end(); ++it)
cout << ' ' << *it;
return 0;
}
#include <iostream>
#include <algorithm>
#include <vector>
#include <functional>
using namespace std;
int op_increase (int i)
{
return ++i;
}
int main ()
{
vector<int> a;
vector<int> b;
for (int i = 1; i < 4; i++)
a.push_back (i * 10);
b.resize(a.size());
transform (a.begin(), a.end(), b.begin(), op_increase);
transform (a.begin(), a.end(), b.begin(), a.begin(), plus<int>());
for (vector<int> :: iterator it = a.begin(); it != a.end(); ++it)
cout << ' ' << *it;
return 0;
}54. Which function is used to get the absolute of a complex number?
55. What will be the output of the following C++ code?
#include <iostream>
using namespace std;
struct A
{
virtual void f()
{
cout << "Class A" << endl;
}
};
struct B : A
{
virtual void f()
{
cout << "Class B" << endl;
}
};
struct C : A
{
virtual void f()
{
cout << "Class C" << endl;
}
};
void f(A* arg)
{
B* bp = dynamic_cast<B*>(arg);
C* cp = dynamic_cast<C*>(arg);
if (bp)
bp -> f();
else if (cp)
cp -> f();
else
arg -> f();
};
int main()
{
A aobj;
C cobj;
A* ap = &cobj;
A* ap2 = &aobj;
f(ap);
f(ap2);
}
#include <iostream>
using namespace std;
struct A
{
virtual void f()
{
cout << "Class A" << endl;
}
};
struct B : A
{
virtual void f()
{
cout << "Class B" << endl;
}
};
struct C : A
{
virtual void f()
{
cout << "Class C" << endl;
}
};
void f(A* arg)
{
B* bp = dynamic_cast<B*>(arg);
C* cp = dynamic_cast<C*>(arg);
if (bp)
bp -> f();
else if (cp)
cp -> f();
else
arg -> f();
};
int main()
{
A aobj;
C cobj;
A* ap = &cobj;
A* ap2 = &aobj;
f(ap);
f(ap2);
}56. Which type of relationship is modelled by Aggregation?
57. What will be the output of the following C++ code?
#include <iostream>
using namespace std;
class Base
{
public:
int m;
Base(int n=0)
: m(n)
{
cout << "Base" << endl;
}
};
class Derived: public Base
{
public:
double d;
Derived(double de = 0.0)
: d(de)
{
cout << "Derived" << endl;
}
};
int main()
{
cout << "Instantiating Base" << endl;
Base cBase;
cout << "Instantiating Derived" << endl;
Derived cDerived;
return 0;
}
#include <iostream>
using namespace std;
class Base
{
public:
int m;
Base(int n=0)
: m(n)
{
cout << "Base" << endl;
}
};
class Derived: public Base
{
public:
double d;
Derived(double de = 0.0)
: d(de)
{
cout << "Derived" << endl;
}
};
int main()
{
cout << "Instantiating Base" << endl;
Base cBase;
cout << "Instantiating Derived" << endl;
Derived cDerived;
return 0;
}58. Which operator is used to produce a certain number in a specific range?
59. What is the use of is_heap_until() function?
60. Which of the following is correct about bitset and vector of bools?
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 8
- C plus plus miscellaneous - Section 9
- C plus plus miscellaneous - Section 10
- C plus plus miscellaneous - Section 11
