I try to remember of how threads work, I see that with C++11
it simplify the creation and utilisation of it. I use the answer to this post Simple example of threading in C++ for just create a simple thread.
But there's difference between me and the answer of the post, I'm not in a main, so I create my thread in a constructor, and it's not the same parameters.
Here's my simple code and what I try to do:
I'm in a class mainWindow.cpp
:
//Constructor
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
// Constructs the new thread and runs it. Does not block execution.
thread t1(lancerServeur, NULL);
ui->setupUi(this);
}
void MainWindow::lancerServeur(){
std::cout << "Le serveur se lance";
}
The errors are :
expected ';' before 't1'
statement cannot resolve address of overloaded function thread t1(lancerServeur, NULL);
I think my parameters for thread t1(lancerServeur, NULL);
are false.
Could you explain me how it works ?
Thanks.