title: c++ assign a reference to property in constructor
body: <p>I need to pass a database connection to a new object instance. However, the following code is not working as wanted.</p>
  
  <pre><code>class child {
    public:
      db_connection Con;
      child(db_connection&amp; Con);
  };
  
  child::child(db_connection&amp; Con) {
    this-&gt;Con = Con;
  }
  </code></pre>
  
  <p>The assignment in constructor raises this error: <strong>use of deleted function....</strong></p>
  
  <p>I know this means it's calling constructor of db_connection to create new object of Con. But that's not what I wish to have.</p>
  
  <p>And I can't declare the property 'Con' in class declaration as</p>
  
  <pre><code>class child {
    public:
      db_connection&amp; Con;
      ...
  </code></pre>
  
  <p>Because a reference must be initialised or assigned. This is a hard situation.</p>