1.

What is the output of this program?
#include <iostream>
#include <functional>
#include <vector>
#include <algorithm>
#include <string>
using namespace std;
int main ()
{
vector <string*> num;
num.push_back ( new string ("First") );
num.push_back ( new string ("Second") );
num.push_back ( new string ("Third") );
num.push_back ( new string ("Fourth") );
num.push_back ( new string ("Fifth") );
vector <int> lengths ( num.size() );
transform (num.begin(), num.end(), lengths.begin(),
mem_fun(&string :: length));
for (int k = 0; k < 5; k++)
{
cout << lengths[k] << " ";
}
return 0;
}

A. 5 6 5 6 5
B. 6 5 6 5
C. 5 6 5
D. 6 5
E. 5
Answer» B. 6 5 6 5


Discussion

No Comment Found

Related MCQs