What happens when you attempt to compile and run the following code?
#include
#include
#include
using namespace std;
template
ostream and out;
Out(ostream and o): out(o){}
void operator()(const T and val ) {
out< } }; struct Sequence { int start; Sequence(int start):start(start){} int operator()() { return start++; } }; int main() { vector vector generate(v1.begin(), v1.end(), Sequence(1)); random(v1.begin(),v1.end()); for_each(v1.begin(), v1.end(), Out return 0; } Program outputs: A. 1 2 3 4 5 6 7 8 9 10 B. 10 9 8 7 6 5 4 3 2 1 C. 8 2 4 9 5 7 10 6 1 3 D. compilation error
What happens when you attempt to compile and run the following code?
#include
#include
#include
#include
using namespace std;
class B { int val;
public:
B(int v):val(v){}
int getV() const {return val;} bool operator > (const B and v) const { return val>v.val;} };
ostream and operator <<(ostream and out, const B and v) { out< template ostream and out; Out(ostream and o): out(o){} void operator() (const T and val ) { out< int main() { int t[]={20, 30, 10, 20, 30, 10, 20, 30, 10, 20}; deque d1(t, t+10); sort(d1.begin(), d1.end(), greater()); pair for_each(result.first, result.second, Out(cout));cout< return 0; } Program outputs: A. 30 30 30 20 20 20 20 10 10 10 B. 20 20 20 20 C. 30 20 20 20 10 D. 20 20 20 20 10 E. 30 20 20 20 20 10
What happens when you attempt to compile and run the following code?
#include
#include
#include
#include
using namespace std;
class B { int val;
public:
B(int v):val(v){}
int getV() const {return val;} bool operator < (const B and v) const { return val ostream and operator <<(ostream and out, const B and v) { out< ostream and out; Out(ostream and o): out(o){} void operator() (const T and val ) { out< int main() { int t[]={8, 10, 5, 1, 4, 6, 2, 7, 9, 3}; deque d1(t, t+10); sort(d1.begin(), d1.end()); set s1(t,t+10); cout< return 0; } Program outputs: A. 1 0 B. 1 1 C. 0 0 D. 0 1 E. compilation error
What happens when you attempt to compile and run the following code?
#include
#include
#include
#include
using namespace std;
class B { int val;
public:
B(int v):val(v){}
int getV() const {return val;} bool operator > (const B and v) const { return val>v.val;} };
ostream and operator <<(ostream and out, const B and v) { out< template ostream and out; Out(ostream and o): out(o){} void operator() (const T and val ) { out< int main() { B t[]={3,2,4,1,5,10,9,7,8,6}; vector v1(t,t+10); cout<<*max_element(v1.begin(), v1.end(), greater()); cout< return 0; } Program outputs: A. 3 B. 1 C. 6 D. 10 E. compilation error
What will happen when you attempt to compile and run the following code?
#include
using namespace std;
class C {};
template
class A {
T_v;
public:
A() {}
A(T v): _v(v){}
T getV() { return _v; }
void add(T a) { _v+=a; }
};
int main()
{
A
A
a.add(C());
cout << b.getV() < return 0; } A. program will display:0 B. program will not compile C. program will compile D. program will cause runtime exception
What will happen when you attempt to compile and run the code below, assuming that you enter the following sequence: true true
#include
#include
using namespace std;
int main ()
{
bool a,b;
cin>>a>>b;
cout< return 0; } Program will output: A. truetrue B. falsefalse C. 11 D. 00 E. none of these
What happens when you attempt to compile and run the following code?
#include
#include
#include
#include
using namespace std;
class B { int val;
public:
B(int v=0):val(v){}
int getV() const {return val;}
B operator +(const B andb )const { return B(val + b.val);} };
ostream and operator <<(ostream and out, const B and v) { out< template ostream and out; Out(ostream and o): out(o){} void operator() (const T and val ) { out< template A operator() (const A and a, const A and b) const { return a+b; }}; int main() { int t[]={1,2,3,4,5,6,7,8,9,10}; vector v1(t, t+10); vector v2(10); transform(v1.begin(), v1.end(), v2.begin(), bind1st(ptr_fun (Add()), 1)); for_each(v2.rbegin(), v2.rend(), Out(cout));cout< return 0; } Program outputs: A. 1 2 3 4 5 6 7 8 9 10 B. 2 3 4 5 6 7 8 9 10 11 C. 10 9 8 7 6 5 4 3 2 1 D. 11 10 9 8 7 6 5 4 3 2 E. compilation error
What happens when you attempt to compile and run the following code?
#include
#include
using namespace std;
bool mycomparison (int first, int second){return first>second;}
template
void print(T start, T end) {
while (start != end) {
std::cout << *start << " "; start++;
}
}
int main()
{
int t1[] ={ 1, 7, 8, 4, 5 };
list
int t2[] ={ 3, 2, 6, 9, 0 };
list
l1.sort(mycomparison);
l2.sort(mycomparison);
l1.merge(l2,mycomparison);
print(l1.begin(), l1.end());
print(l2.begin(), l2.end()); cout< return 0; } A. program outputs: 9 8 7 6 5 4 3 2 1 0 B. program outputs: 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 C. program outputs: 9 8 7 6 5 4 3 2 1 0 9 6 3 2 0 D. program outputs: 0 1 2 3 4 5 6 7 8 9 0 2 3 6 9 E. program outputs: 0 1 2 3 4 5 6 7 8 9
What happens when you attempt to compile and run the following code? Choose all that apply.
#include
#include
using namespace std;
int main ()
{
vector
v1.push_back(3);
cout< return 0; } A. program displays 4 4 B. program displays 10 3 C. size of vector v1 is 11 D. all elements of vector v1 are of the same value
What happens when you attempt to compile and run the following code? Choose all possible answers.
#include
using namespace std;
class C {
public:
int _c;
C():_c(0){}
C(int c) { _c = c;}
C operator+=(C and b) {
C tmp; tmp._c = _c+b._c;
return tmp;
} };
ostream and operator<<(ostream and c, const C and v) {
c< template class A { T_v; public: A() {} A(T v): _v(v){} T getV() { return _v; } void add(T and a) { _v+=a; } }; int main() { A A a.add(C()); cout << a.getV() < return 0; } A. program will display:5 B. program will not compile C. program will compile D. program will cause runtime exception
Nowadays, the certification exams become more and more important and required by more and more enterprises when applying for a job. But how to prepare for the exam effectively? How to prepare for the exam in a short time with less efforts? How to get a ideal result and how to find the most reliable resources? Here on Vcedump.com, you will find all the answers. Vcedump.com provide not only C++ Institute exam questions, answers and explanations but also complete assistance on your exam preparation and certification application. If you are confused on your CPP exam preparations and C++ Institute certification application, do not hesitate to visit our Vcedump.com to find your solutions here.