title: C++ common interface for "cin" and "File"
body: <p>Is there a common interface for cin and file input?</p>
  
  <p>I want to make a program that has an optional parameter</p>
  
  <pre><code>prog [input-file]
  </code></pre>
  
  <p>If an input file is specified, then it should read from the file, and if not, it should read from cin.</p>
  
  <p>From what I can tell, they both implement <code>istream</code>. How would you set up it so that I could do something like <code>in &gt;&gt; var</code>, where <code>in</code> is an <code>istream</code>.</p>