[Solved] Is the code valid. If i want to display first element? if not then what will s.begin() return?


In C++, the begin() member function returns a pointer (or iterator) to the front (a lot of the time, anyways).

You can access the first element with begin(), but you have to dereference it (like a pointer) first:

cout << *s.begin(); // 5

Here is a demo: https://repl.it/JQiU/0

solved Is the code valid. If i want to display first element? if not then what will s.begin() return?