expected class-name before ‘{’ token error

168 views Asked by At

I'm working on SFML here and I want to create my own RenderWindow class with Legacy. But the g++ prints this error: expected class-name before ‘{’ token at line 7 in .hpp

I all ready ask Google about it but I didn't find what I was expecting at so I hope you will be able to help me to find this out :)

my_render_window.hpp

#ifndef MY_RENDER_WINDOW_HPP_
# define MY_RENDER_WINDOW_HPP_

# include <SFML/Window.hpp>

class MyRenderWindow : public sf::RenderWindow
{
public:
  MyRenderWindow();

protected:

};

#endif /* !MY_RENDER_WINDOW_HPP_ */

my_render_window.cpp

#include "my_render_window.hpp"

MyRenderWindow::MyRenderWindow(): sf::RenderWindow()
{

}

I compile correctly without these files and taking base sf::RenderWindow class to run with.

1

There are 1 answers

2
Rodolphe Chartier On BEST ANSWER

Okay, I dont know why but with this include #include <SFML/Graphics.hpp> just after the #include <SFML/Window.hpp> it works !

So weird... :( #include <SFML/Graphics.hpp> may includes a file that I need to.