title: C++ compiles but gives error when executed
body: <p>I am new to Linux Ubuntu 11.10 and have basic C++exposure.</p>
  
  <p>I installed the g++ by </p>
  
  <pre><code>sudo apt-get install build-essential
  </code></pre>
  
  <p>and created a directory cpp in my home directory. I then wrote a program hello.cpp in my cpp directory</p>
  
  <pre><code>#include &lt;iostream&gt;
  using namespace std;
  
  int main() {
      cout &lt;&lt; "Hello !" ; return 0;
  }
  </code></pre>
  
  <p>and compiled using </p>
  
  <pre><code>g++ -W hello.cpp -o hello
  </code></pre>
  
  <p>The program compiles without any errors/warnings. When I try to execute the file</p>
  
  <pre><code>./hello.cpp
  </code></pre>
  
  <p>I get error messages:</p>
  
  <pre><code>line 3: using: command not found
  line 6: syntax error near unexpected token `('
  line 6: `int main() {'
  </code></pre>
  
  <p>I tried looking at a lot of posts but could not resolve this. I have MS VisualStudio on Windows, but I would rather learn C++ on Ubuntu. Thanks in advance.</p>