2
« on: April 06, 2012, 07:07:06 am »
I'm not sure what I am doing wrong, all I want is to be able to use the thread example but in a different class.
Here are a couple of the errors I get:
error: no matching function for call to 'sf::Thread::Thread(void (Foo::*)(void*))'|
Main
#include <SFML/System.hpp>
#include <iostream>
#include "Foo.h"
int main()
{
// Create a thread with our function
// Start it !
Foo bar;
bar.init();
// Print something...
for (int i = 0; i < 10; ++i)
std::cout << "I'm the main thread" << std::endl;
return EXIT_SUCCESS;
}
Foo.h
#ifndef FOO
#define FOO
#include <SFML/Graphics.hpp>
#include <SFML/Window.hpp>
#include <SFML/System.hpp>
class Foo{
public:
void ThreadFunction(void*);
void init();
};
#endif
Foo.cpp
#include <SFML/Graphics.hpp>
#include <SFML/Window.hpp>
#include <SFML/System.hpp>
#include <iostream>
#include "Foo.h"
void Foo::ThreadFunction(void* UserData)
{
// Print something...
for (int i = 0; i < 10; ++i)
std::cout << "I'm the thread number 1" << std::endl;
}
void Foo::init(){
sf::Thread Thread(&ThreadFunction);
//Tried these as well, did not work
//sf::Thread Thread(&Foo::ThreadFunction);
//sf::Thread Thread(ThreadFunction());
Thread.Launch();
}