Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Weird error with sf namespace and LineStrip  (Read 4943 times)

0 Members and 1 Guest are viewing this topic.

nick1702

  • Newbie
  • *
  • Posts: 3
    • View Profile
    • Email
Weird error with sf namespace and LineStrip
« on: December 04, 2021, 07:19:30 am »
Hi, I am programming a project and am using SFML and I have gotten strange error. Everytime I try and create a vertex array in my header file I get an error saying that LineStrip does not exist in sf namespace. However, in the cpp file that includes that header file I can use sf::LineStrip without any errors. I am not sure how this error is occurring and would greatly appreciate some help. Thanks.

kojack

  • Sr. Member
  • ****
  • Posts: 343
  • C++/C# game dev teacher.
    • View Profile
Re: Weird error with sf namespace and LineStrip
« Reply #1 on: December 04, 2021, 08:37:48 am »
When declaring a variable in a class, you can't call its constructor with parameters. You need to move the parameters to an initialiser list in the cpp file for the curveObject constructor.
For example...
Header:
class curveObject : public sf::Transformable{
   private:
      sf::VertexArray points;
   public:
   curveObject();
//etc
 
CPP:
curveObject::curveObject():points(sf::LineStrip, 4)
{
}
 

nick1702

  • Newbie
  • *
  • Posts: 3
    • View Profile
    • Email
Re: Weird error with sf namespace and LineStrip
« Reply #2 on: December 04, 2021, 09:43:23 pm »
Thank you, I decided to switch to a vector of vertexes and it ended up working. Thanks!