title: How to pass object by reference to a constructor
body: <p>I would like to pass by reference an object to a Contructor, but I get problems, because I don't know how do bound it to the variable of the class.</p>
  
  <p>Here I post some pieces of my code and the error risen.</p>
  
  <pre><code>class ShortestPath{
      public:
          ShortestPath(Graph&amp; graph): graph(graph){};[...]
      private:
          Graph *graph; 
  };
  </code></pre>
  
  <p>in this case the error risen is:</p>
  
  <pre><code>cannot convert `Graph' to `Graph*' in initialization 
  </code></pre>
  
  <p>and if I write </p>
  
  <pre><code>ShortestPath(Graph&amp; graph): *graph(graph){};[...]
  </code></pre>
  
  <p>the error is</p>
  
  <pre><code>expected identifier before '*' token 
  </code></pre>
  
  <p>and when I call the constructor should I call like this?
  ShortestPath(Graph);</p>