Page 1 of 1

Warum erhalte ich beim Erstellen eines Threads für diese Funktion eine Fehlermeldung? [Duplikat]

Posted: 16 Jan 2025, 07:07
by Guest
Ich habe eine Funktion erstellt, die im Laufe der Zeit einen String ausliest. Es funktioniert gut, wenn Sie es alleine aufrufen, aber wenn ich versuche, einen neuen Thread für die Funktion zu erstellen, erhalte ich viele Fehler. Eine andere Grundfunktion funktioniert jedoch einwandfrei.

Code: Select all

void talk(std::string& string)
{
for (volatile int i{0}; i < string.length(); ++i)
{
if (string[i] != '\n')
{
if (i > 0 && string[i - 1] == '\n') std::cout &), std::__cxx11::basic_string, std::allocator > > >’
258 |           _M_invoke(_Index_tuple)
|           ^~~~~~~~~
/usr/include/c++/11/bits/std_thread.h:262:9: error: no type named ‘type’ in ‘struct std::thread::_Invoker, std::allocator >&), std::__cxx11::basic_string, std::allocator > > >::__result, std::allocator >&), std::__cxx11::basic_string, std::allocator > > >’
262 |         operator()()
|         ^~~~~~~~