Vidyalelo
C++ Programming · Q59

Standard Template Library (STL) in C++

Programming · C++ Programming · question 59

Q59

What will be the output of the following C++ code? #include #include #include using namespace std ; typedef list 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;

A.
test
B.
test one
C.
test two
D.
test: one
two
test: one
two
test: three
three
three
test: three
three
Answer

Answer: Option D

Solution

Answer: Option D
No explanation is given for this question Let's Discuss on Board