title: Copy constructors - c++
body: <p>Can I write a copy constructor by just passing in a pointer instead of the const reference?  (Would it be ok if I make sure that I am not going to change any values though?)</p>
  
  <p>Like so:</p>
  
  <pre><code>SampleClass::SampleClass(SampleClass* p)
  {
   //do  the necessary copy functionality
  }
  </code></pre>
  
  <p>instead of:</p>
  
  <pre><code>SampleClass::SampleClass(const SampleClass&amp; copyObj)
  {
  //do the necessary copy
  }
  </code></pre>
  
  <p>Thanks in advance.</p>
  
  <hr>
  
  <p>Thanks everyone. So, if I write a constructor that takes in a pointer( and thought that's my copy constructor), the compiler would still supply with the default copy constructor in which case my constructor( which i thought was my copy constructor) would not be called and the default copy constructor would be called. Got it.</p>