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

Author Topic: Structure syntax  (Read 2409 times)

0 Members and 1 Guest are viewing this topic.

Abragon

  • Newbie
  • *
  • Posts: 10
    • View Profile
    • Email
Structure syntax
« on: October 23, 2017, 12:22:06 am »
I am going through the SFML game development by example book and in this chapter they have an advance structure that I would like some help on.
struct Binding {
   Binding(const std::string& l_name)
      : m_name(l_name), m_details(l_name), c(0) {}
   void BindEvent(EventType l_type,
      EventInfo l_info = EventInfo())
   {
      m_events.emplace_back(l_type, l_info);
   }
   Events m_events;
   std::string m_name;
   int c; // Count of events that are "happening".
   EventDetails m_details;
};


particularly of interest is the 2nd and 3rd line after the header. I am not sure exactly what is being declared.

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11034
    • View Profile
    • development blog
    • Email
Re: Structure syntax
« Reply #1 on: October 23, 2017, 07:38:05 am »
It's called initialization list. If you're not familiar with that, then you should probably put down the SFML book for a bit and read a basic C++ book. ;)
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

Abragon

  • Newbie
  • *
  • Posts: 10
    • View Profile
    • Email
Re: Structure syntax
« Reply #2 on: October 23, 2017, 11:39:28 pm »
Thanks for the heads-up  ;D!!!