title: C++ pass pointer by reference and assign default value
body: <p>I would like to pass a pointer by reference to a function, such that i can actually change the address the passed pointer is pointing to and i'd like to assign this argument a default value.</p>
  
  <p>something like this:</p>
  
  <p>in the declaration</p>
  
  <pre><code>void myFunc(SomeType* &amp;var=NULL);
  </code></pre>
  
  <p>and the definition:</p>
  
  <pre><code>void MyClass::myFunc(SomeType* &amp;var){
      if(var!=NULL)
          (*var)=(*someOtherPointer);
  
      if(someCondition)
          var=NULL;
  }
  </code></pre>
  
  <p>such that a callee can decide whether he wants to call the function with one argument or without argument. And sucht that if he decides to pass an argument, and someCondition holds, the passed pointer will point to NULL afterwards</p>
  
  <p>however - if i try to do it like this i get a:</p>
  
  <p>Error C2440: 'default argument': 'int' cannot be conveted to 'SomeType *&amp;'</p>
  
  <p>Thanks for the help!</p>