hi all, especially JLBorges who has been extremely helpful.
i split time learning from books and youtube tutorials (while practicing coding questions on hackerrank, which is often not clearly worded)
when i encounter problems, such as the one below. i'll try googling and reading the books again. but when i'm stuck, i'll come here
would you advise me how i can edit the code to let it compile? (i use gcc on my macbook terminal). i'm following this code example on youtube, sees it get compiled successfully but i can't reproduce the results.
non-aggregate type 'set<int>' cannot be initialized with an initializer list
set<int> Set = {1,2,5,4,3,1,2,3,4,5};
^ ~~~~~~~~~~~~~~~~~~~~~
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
|
#include <iostream>
#include <set>
#include <string>
#include <functional>
using namespace std;
int main()
{
set<int> Set = {1,2,5,4,3,1,2,3,4,5};
for(const auto& e: Set)
{
cout << e << endl;
}
return 0;
}
|