title: How to move a struct into a class?
body: <p>I've got something like:</p>
  
  <pre><code>typedef struct Data_s {
    int field1;
    int field2;
  } Data;
  
  class Foo {
    void getData(Data&amp; data);
    void useData(Data&amp; data);
  }
  </code></pre>
  
  <p>In another class's function, I might do:</p>
  
  <pre><code>class Bar {
    Data data_;
    void Bar::taskA() {
      Foo.getData(data_);
      Foo.useData(data_);
    }
  }
  </code></pre>
  
  <p>Is there a way to move the Data out of the global scope and into Foo without creating a new class? Data mirrors a struct existing in a library I'm using elsewhere. (i.e. same fields, just different name. I cast Data into the other struct later. I do this because Foo is an abstract class, and the derived class using the library is just one of many.)</p>
  
  <p>Currently, just pasting it inside the class and replacing <code>Data</code> with <code>Foo::Data</code> everywhere doesn't work.</p>
  
  <pre><code>class Foo {
    typedef struct Data_s {
      int field1;
      int field2;
    } Data;
    ...
  }
  </code></pre>
  
  <p>I get <code>'Data' in class 'Foo' does not name a type</code> at <code>Bar data_;</code></p>