I've got a class with a simple thread pointer, that I use to start a function in a new thread from my constructor.
class Tty {
public:
Tty();
private:
void foo();
std::thread tFoo;
};
using namespace std;
Tty::Tty() {
tFoo = thread(&Tty::foo, this);
}
void Tty::foo() {
cout << "test";
}
My main can be resumed to that:
int main(int argc, char** argv) {
Tty* tty = new Tty();
while (!exitCheck());
}
But when I run this code, I got this error at runtime: malloc(): memory corruption: 0x000000000133c170
.
What did I do wrong ?