1
System / Re: sf :: Thread inside a class
« on: May 13, 2012, 10:10:27 pm »...Hah, thanks. I'll use this.
EDIT: No luck, unfortunately. Here's the updated code:
#ifndef SHAPECONTAINER_H
#define SHAPECONTAINER_H
#include <SFML/Graphics.hpp>
#include <SFML/System.hpp>
class shapeContainer {
public:
shapeContainer ( ) : runthread ( & shapeContainer :: threadFunction , this ) { }
shapeContainer ( );
void setType ( int input );
int getType ( );
void setLocation ( int x1 , int y1 , int x2 , int y2 );
sf :: RenderWindow * drawShape ( sf :: RenderWindow * window , sf :: Color color );
private:
void threadFunction ( ) { }
int type , xl1 , xl2 , yl1 , yl2;
sf::Thread runthread;
};
#endif
and the output:#define SHAPECONTAINER_H
#include <SFML/Graphics.hpp>
#include <SFML/System.hpp>
class shapeContainer {
public:
shapeContainer ( ) : runthread ( & shapeContainer :: threadFunction , this ) { }
shapeContainer ( );
void setType ( int input );
int getType ( );
void setLocation ( int x1 , int y1 , int x2 , int y2 );
sf :: RenderWindow * drawShape ( sf :: RenderWindow * window , sf :: Color color );
private:
void threadFunction ( ) { }
int type , xl1 , xl2 , yl1 , yl2;
sf::Thread runthread;
};
#endif
Code: [Select]
In file included from ./main.cpp:1:
./shapecontainer.h:8: error: ‘shapeContainer::shapeContainer()’ cannot be overloaded
./shapecontainer.h:7: error: with ‘shapeContainer::shapeContainer()’
./shapecontainer.h: In constructor ‘shapeContainer::shapeContainer()’:
./shapecontainer.h:7: error: no matching function for call to ‘sf::Thread::Thread(void (shapeContainer::*)(), shapeContainer* const)’
/usr/include/SFML/System/Unix/Thread.hpp:92: note: candidates are: sf::Thread::Thread()
/usr/include/SFML/System/Unix/Thread.hpp:57: note: sf::Thread::Thread(void (*)(void*), void*)
/usr/include/SFML/System/Unix/Thread.hpp:45: note: sf::Thread::Thread(const sf::Thread&)
In file included from ./gamewindow.cpp:1:
./shapecontainer.h:8: error: ‘shapeContainer::shapeContainer()’ cannot be overloaded
./shapecontainer.h:7: error: with ‘shapeContainer::shapeContainer()’
./shapecontainer.h: In constructor ‘shapeContainer::shapeContainer()’:
./shapecontainer.h:7: error: no matching function for call to ‘sf::Thread::Thread(void (shapeContainer::*)(), shapeContainer* const)’
/usr/include/SFML/System/Unix/Thread.hpp:92: note: candidates are: sf::Thread::Thread()
/usr/include/SFML/System/Unix/Thread.hpp:57: note: sf::Thread::Thread(void (*)(void*), void*)
/usr/include/SFML/System/Unix/Thread.hpp:45: note: sf::Thread::Thread(const sf::Thread&)
In file included from /usr/include/SFML/System/Thread.hpp:40,
from /usr/include/SFML/System.hpp:38,
from /usr/include/SFML/Window.hpp:32,
from /usr/include/SFML/Graphics.hpp:32,
from ./shapecontainer.h:3,
from ./gamewindow.cpp:1:
/usr/include/SFML/System/NonCopyable.hpp: In member function ‘sf::Thread& sf::Thread::operator=(const sf::Thread&)’:
/usr/include/SFML/System/NonCopyable.hpp:64: error: ‘sf::NonCopyable& sf::NonCopyable::operator=(const sf::NonCopyable&)’ is private
/usr/include/SFML/System/Unix/Thread.hpp:45: error: within this context
In file included from ./gamewindow.cpp:1:
./shapecontainer.h: In member function ‘shapeContainer& shapeContainer::operator=(const shapeContainer&)’:
./shapecontainer.h:5: note: synthesized method ‘sf::Thread& sf::Thread::operator=(const sf::Thread&)’ first required here
./gamewindow.cpp: In member function ‘void GameWindow::drawGameWindow(sf::RenderWindow*, sf::Color, int, int, int)’:
./gamewindow.cpp:13: note: synthesized method ‘shapeContainer& shapeContainer::operator=(const shapeContainer&)’ first required here
In file included from /usr/include/SFML/System/Thread.hpp:40,
from /usr/include/SFML/System.hpp:38,
from /usr/include/SFML/Window.hpp:32,
from /usr/include/SFML/Graphics.hpp:32,
from ./shapecontainer.h:3,
from ./gamewindow.cpp:1:
/usr/include/SFML/System/NonCopyable.hpp: In copy constructor ‘sf::Thread::Thread(const sf::Thread&)’:
/usr/include/SFML/System/NonCopyable.hpp:57: error: ‘sf::NonCopyable::NonCopyable(const sf::NonCopyable&)’ is private
/usr/include/SFML/System/Unix/Thread.hpp:45: error: within this context
In file included from ./gamewindow.cpp:1:
./shapecontainer.h: In copy constructor ‘shapeContainer::shapeContainer(const shapeContainer&)’:
./shapecontainer.h:5: note: synthesized method ‘sf::Thread::Thread(const sf::Thread&)’ first required here
./gamewindow.cpp: In member function ‘shapeContainer GameWindow::shapeAt(int, int)’:
./gamewindow.cpp:40: note: synthesized method ‘shapeContainer::shapeContainer(const shapeContainer&)’ first required here
In file included from ./shapecontainer.cpp:2:
./shapecontainer.h:8: error: ‘shapeContainer::shapeContainer()’ cannot be overloaded
./shapecontainer.h:7: error: with ‘shapeContainer::shapeContainer()’
./shapecontainer.h: In constructor ‘shapeContainer::shapeContainer()’:
./shapecontainer.h:7: error: no matching function for call to ‘sf::Thread::Thread(void (shapeContainer::*)(), shapeContainer* const)’
/usr/include/SFML/System/Unix/Thread.hpp:92: note: candidates are: sf::Thread::Thread()
/usr/include/SFML/System/Unix/Thread.hpp:57: note: sf::Thread::Thread(void (*)(void*), void*)
/usr/include/SFML/System/Unix/Thread.hpp:45: note: sf::Thread::Thread(const sf::Thread&)
./shapecontainer.cpp: At global scope:
./shapecontainer.cpp:4: error: redefinition of ‘shapeContainer::shapeContainer()’
./shapecontainer.h:7: error: ‘shapeContainer::shapeContainer()’ previously defined here