title: Overload operator<< and >> in a c++ struct
body: <p>I have a class and a structure inside the class like that :</p>
  
  <pre><code>class MyClass : public QObject
  {
  public:
      ....
  
      struct MyStruct
      {
         quint8 val1;
      }
  };
  </code></pre>
  
  <p>I would like to overload the operators &lt;&lt; and >> for the struct, but I don't know how to do. For the moment, I do like that :</p>
  
  <pre><code>class MyClass : public QObject
  {
  public:
      ....
  
      struct MyStruct
      {
         quint8 val1;
  
         QDataStream &amp;operator&lt;&lt;(QDataStream &amp;out, const MyStruct&amp; _myStruct)
         {
             out &lt;&lt; _myStruct.val1;
             return out;
         }
  
         QDataStream &amp;operator&gt;&gt;(QDataStream &amp;in, MyStruct&amp; _myStruct)
         {
             in &gt;&gt; _myStruct.val1;
             return in;
         }
      };
  };
  </code></pre>
  
  <p>but it is not OK</p>