ExamVeda
Login
Home
Standard Template Library (STL) in C plus plus
?

What will be the output of the following C++ code?
#include <list>
#include <string>
#include <iostream>
using namespace std ;
typedef list<string> LISTSTR; 
int main()
{
    LISTSTR :: iterator i;
    LISTSTR test;
    test.insert(test.end(), "one");
    test.insert(test.end(), "two");
    LISTSTR test2(test);
    LISTSTR test3(3, "three");
    LISTSTR test4(++test3.begin(),
    test3.end());
    cout << "test:";
    for (i =  test.begin(); i != test.end(); ++i)
        cout << " " << *i << endl;
    cout << "test:";
    for (i =  test2.begin(); i != test2.end(); ++i)
        cout << " " << *i << endl;
    cout << "test:";
    for (i =  test3.begin(); i != test3.end(); ++i)
        cout << " " << *i << endl;
    cout << "test:";
    for (i =  test4.begin(); i != test4.end(); ++i)
        cout << " " << *i << endl;
}

Answer & Solution
Correct Answer: Option D
Let's discuss the solution. Join the discussion
Examveda
Question posted by Examveda
Community

Join the Discussion

No comments yet Be the first to discuss this question.