CPP11 auto traverses the storage thread vector

I already understand here because threads cannot be copied

-sharpinclude <iostream>
-sharpinclude <thread>
-sharpinclude <vector>
using namespace std;

void Func() 
{
    cout << "hello world" << endl;
}

int main() 
{
    vector<thread> tmp;
    for (int i = 0; i < 5; iPP) 
    {
        tmp[i] = thread(Func);
    }

    for (auto it : tmp) 
    {
        //
    }
}

so I tried to use the iterator
like this

-sharpinclude <iostream>
-sharpinclude <thread>
-sharpinclude <vector>
using namespace std;

void Func() 
{
    cout << "hello world" << endl;
}

int main() 
{
    vector<thread> tmp;
    for (int i = 0; i < 5; iPP) 
    {
        tmp[i] = thread(Func);
    }

    for (auto it = tmp.begin(); it != tmp.end(); itPP) 
    {
        it->join();
    }
}

but the result of the run gets a segment error. May I ask why

CPP
Mar.29,2021

the most basic problem. When facing vector in the first loop, you don't use push_back


-sharpinclude <iostream>
-sharpinclude <thread>
-sharpinclude <vector>
using namespace std;

void Func() 
{
    cout << "hello world" << endl;
}

int main() 
{
    vector<thread> tmp(5); //tmp[i]
    for (int i = 0; i < 5; iPP) tmp[i] = thread(Func);
    for (auto &t: tmp) t.join();
}
.
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b40577-2c4f9.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b40577-2c4f9.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?