title: How can I terminate early a function that is defined in another file?
body: <p>I have a file where I'm trying to overload some operators and it's supposed to terminate early given some condition. This file is separate from the main file</p>
  
  <pre><code>#include "MY.h"
  // this file is MY.cpp
  // MY is a class
  
  int&amp; MY::operator[](int i) {
      if (/* condition is met */) exit(1);
      else {/* proceed... */}
  }
  </code></pre>
  
  <p>If I compile that, it gives me this error</p>
  
  <blockquote>
    <p>c:/mingw/bin/../lib/gcc/mingw32/5.3.0/../../../libmingw32.a(main.o):(.text.startup+0xa0):
    undefined reference to `WinMain@16' collect2.exe: error: ld returned 1
    exit status</p>
  </blockquote>
  
  <p>But let's say I have a <code>main()</code> with nothing in it, like so:</p>
  
  <pre><code>// same stuff as above code
  
  int main() {}
  </code></pre>
  
  <p>The new code with an empty <code>main()</code> function will compile with no complaints.</p>
  
  <p>Now, I have another file and the actual <code>main()</code> that I want to use is in this file:</p>
  
  <pre><code>#include "MY.cpp"
  
  int main() { /* some code... */}
  </code></pre>
  
  <p>If I compile this file, it gives me this error: </p>
  
  <blockquote>
    <p>error: redefinition of 'int main()'</p>
  </blockquote>
  
  <p>The obvious way to fix this is to get rid of <code>main()</code> in <code>MY.cpp</code>, but doing that will give me the first error about a returned 1 exit status (don't even know what that means).</p>
  
  <p>**So the bottom line is this: How can I terminate a function if that function is defined in another file that I'm including in my main file? **</p>