title: Objective-C multiple class definitions in one .h and .m
body: <p>I have two subclasses, one that has a lot of customization, we'll call it Foo, and another sub class that only needs 1 method overridden, and doesn't need any additional variables, we'll call it Bar.</p>
  
  <p>Bar will be one of the variables of Foo, so to keep from having 2 more files to work with (.m and .h for Bar) I would like to interface and implement Bar in Foo's .h and .m files.</p>
  
  <p>My best effort gives me several compiler errors.</p>
  
  <p>The .h file looks like:</p>
  
  <pre><code>#import &lt;UIKit/UIKit.h&gt;
  
  @interface Foo : FooSuperClass {
      Bar *barVariable;
  }
  
  @property (nonatomic, retain) Bar *barVariable;
  
  -(void) fooMethod;
  @end
  
  @interface Bar : BarSuperClass {
  }
  
  @end
  </code></pre>
  
  <p>The .m file looks like:</p>
  
  <pre><code>#import "Foo.h"
  
  
  @implementation Foo
  @synthesize barVariable;
  
  -(void) fooMethod{
    //do foo related things
  }
  @end
  
  @implementation Bar
  - (void)barSuperClassMethodIWantToOverride{
  }
  @end
  </code></pre>
  
  <p>I realize that this type of things would generally be frowned upon, but I feel it's appropriate in my situation.  The first error I get is "expected specifier-qualifier-list before Bar".</p>
  
  <p>What have I done wrong, I'm pretty sure it's possible to have multiple declarations/definitions in a single file.</p>