Which of the following(s) is/are the correct way of assigning values to a forward_list f?

a) f.assign({1,2,3,4,5})
b) f.assign(10,5)
c) both f.assign({1,2,3,4,5}) and f.assign(10,5)
d) f.assign(1,1,1,1)

1 thought on “Which of the following(s) is/are the correct way of assigning values to a forward_list f?”

  1. c
    Explanation: Both f.assign({1,2,3,4,5}) and f.assign(10,5) are correct way of assigning values to a forward_list. The first assignment initializes the list with the elements 1,2,3,4 and 5 whereas the second assignment initializes the list 10 elements with value 5 i.e. 5 10 times.

Leave a Comment