Functions in Structures ? C++

I understand how a basic(?) struct works in C++ shown below as an example.

struct Options 
{
   int num_particles;
   bool use_lbp;
   string infile;
   string outfile;
};

However, I do not understand this added section. What is the purpose of Options(): and what can I do with it ?

struct Options 
{
   Options()
      :num_particles(NUM_PARTICLES),
       use_lbp(false),
       infile(),
       outfile()
   {}

   int num_particles;
   bool use_lbp;
   string infile;
   string outfile;
};

Similarly, I have no idea what is going on in the code below.

struct State_
{
   State_( State pp ) : p( pp ) { }
   operator State() { return p; }
   State p;
};

Is there any website that I can visit, videos I can watch to learn fully about structures and C++ ? Advanced level C++ ? The one I learnt in school was pretty basic which seemed to suffice until now. I hope posting just small fractions of the code is enough as my only doubts are regarding structures.


Source: c++

Leave a Reply