title: using boost::serialize declared in struct into another struct
body: <p>I am new to programming and C++ and seem to have run into this problem.</p>
  
  <p>I am creating a config file with various sensor offsets, and storing it as xml that can be read by other classes using boost::serialization load.</p>
  
  <p>As all sensors have the same kind of offset, I want to make a generic struct with offset definitions. I would like to keep the serialize and save/load in the generic stuct and only instantiate in a different struct when need be.</p>
  
  <p>Each sensor has its own struct, so the other classes only need to use the sensor struct they need.</p>
  
  <p>Originally, I had the serialize/save/load in each sensor struct, and it worked fine. But after moving this to generic struct I cant seem to be able to call it. </p>
  
  <p>The code is: </p>
  
  <pre><code>10 #pragma once
   11 #ifndef OFFSET_CONFIG_H
   12 #define OFFSET_CONFIG_H
   13 
   14 #include &lt;boost/archive/xml_oarchive.hpp&gt;
   15 #include &lt;boost/archive/xml_iarchive.hpp&gt;
   16 #include &lt;boost/serialization/nvp.hpp&gt;
   17 #include &lt;fstream&gt;
   18 #include &lt;string&gt;
   19 
   20 typedef struct Offset
   21 {
   22     std::string name;            // Offsets type.
   23     double offsetX;
   24     double offsetY;
   25     double offsetZ;
   26     double roll;
   27     double pitch;
   28     double yaw;
   29 
   30     template&lt;class Archive&gt;
   31     void serialize(Archive &amp; ar, const unsigned int version)
   32     {
   33         using boost::serialization::make_nvp;
   34         ar &amp; make_nvp("offsetType", name);
   35         ar &amp; make_nvp("OffsetX", offsetX);
   36         ar &amp; make_nvp("OffsetY", offsetY);
   37         ar &amp; make_nvp("OffsetZ", offsetZ);
   38         ar &amp; make_nvp("Roll", roll);
   39         ar &amp; make_nvp("Pitch", pitch);
   40         ar &amp; make_nvp("Yaw", yaw);
   41     }
   42 
   43     void save(const std::string&amp; filename)
   44     {
   45         std::fstream ofs(filename.c_str(), std::fstream::trunc | std::fstream::out);
   46         boost::archive::xml_oarchive xml(ofs);
   47         xml &lt;&lt; boost::serialization::make_nvp("temp", *this);
   48     }
   49 
   50 };
   51  
   70 struct LaserOffset
   71 {
   72   Offset laser;
   90   laser.serialize(Archive &amp; ar, const unsigned int version);
   91   //laser.save(const std::string&amp; filename);
   98 };
  
  168 #endif
  </code></pre>
  
  <p>The error it is throwing currently is:</p>
  
  <pre><code>OffsetConfig.h:90: error: ISO C++ forbids declaration of ‘laser’ with no type 
  
  OffsetConfig.h:90: error: expected ‘;’ before ‘.’ token
  </code></pre>
  
  <p>Can anyone help me with what am I doing wrong? and how to use the serialise/save elements from the struct and maybe how to save it for individual structs? </p>