title: How do I use __FILE__ and __LINE__ as default parameters in a constructor in c++?
body: <p>I'm trying to use the <code>__FILE__</code> and <code>__LINE__</code> macros in a constructor as default parameters, but I can't seem to get the macros to use the right files. They keep expanding from my header file.</p>
  
  <p>In more detail: I'd like to have the file and line number from where an object is instantiated as members of my class. But I don't want to have to go and put the parameters in by hand every time I want to use the objects. I know there's a way to do this, but I can't for the life of me figure it out. What I'm currently doing is the following:</p>
  
  <p>In my header file:</p>
  
  <pre><code>mnNumber( float x, const char* filename = __FILE__, int linenumber = __LINE__ ): 
            value( x ), mFileName( filename ), mFunctionName( nullptr ), mLineNumber(     linenumber ), mID( 0 )
  </code></pre>
  
  <p>But, <strong>FILE</strong> and <strong>LINE</strong> get expanded as if they're from my header file, not the actual location I use the mnNumber.</p>
  
  <p>To answer the question of why I would like to do this, I want to have the code read it's own codepage. The particular values that I use are being registered in a manager, and their value is allowed to be edited by the end user. When the end user is done editing the value, the value is written back into the code page. So, I need to know where the value came from. I also allow the end user to say that they'll never need to edit this value again, and when they click that button, the value is converted from an mnNumber back into a float, and the type on the codepage is rewritten as a float. Or, will be...hopefully.</p>
  
  <p>Any advice for me?</p>