title: Problem compiling simple C++ progam
body: <p>I was provided this simple C++ [I think] program to investigate the maximum size of int that can be stored:</p>
  
  <pre><code>#include &lt;limits.h&gt;
  #include &lt;iostream&gt;
  
  void main ( int argc , char * argv[])
  
  {
  
    cout &lt;&lt; "INT_MAX      " &lt;&lt; INT_MAX   &lt;&lt; endl ;
    cout &lt;&lt; "INT_MAX +1 = " &lt;&lt; INT_MAX + 1  &lt;&lt; endl ;
    cout &lt;&lt; "INT_MAX -1 = " &lt;&lt; INT_MAX - 1 &lt;&lt; endl ;
  
    cout &lt;&lt; "INT_MAX / INT_MAX        " &lt;&lt; INT_MAX /INT_MAX &lt;&lt; endl ;
    cout &lt;&lt; "(INT_MAX +1) / INT_MAX   " &lt;&lt; (INT_MAX +1) /INT_MAX &lt;&lt; endl;
    cout &lt;&lt; "(INT_MAX -1) / INT_MAX   " &lt;&lt; (INT_MAX -1) /INT_MAX  &lt;&lt;endl;
    cout &lt;&lt; "INT_MAX / (INT_MAX +1)   " &lt;&lt; INT_MAX  /(INT_MAX+1)  &lt;&lt;endl;
    cout &lt;&lt; "INT_MAX / (INT_MAX -1)   " &lt;&lt; INT_MAX  /(INT_MAX -1)  &lt;&lt;endl;
  
  }
  </code></pre>
  
  <p>I'm attempting to compile with:</p>
  
  <pre><code>gcc -o int_max int_max.cpp
  </code></pre>
  
  <p>But I get the following error:</p>
  
  <pre><code>int_max.cpp:4: error: '::main' must return 'int'
  int_max.cpp: In function 'int main(int, char**)':
  int_max.cpp:8: error: 'cout' was not declared in this scope
  int_max.cpp:8: error: 'endl' was not declared in this scope
  int_max.cpp:9: warning: integer overflow in expression
  int_max.cpp:13: warning: integer overflow in expression
  int_max.cpp:15: warning: integer overflow in expression
  </code></pre>
  
  <p>I tried adding a return 0 at the end of main but that didn't help.  Any idea what I've done wrong?</p>
  
  <p>P.S It's possible this is actually a C snippet but I seem to remember the lecturer saying it was C++.</p>
  
  <p>Cheers</p>