title: How to initialize a const field in constructor?
body: <p>Imagine I have a C++ class Foo and a class Bar which has to be created with a constructor in which a Foo pointer is passed, and this pointer is meant to remain immutable in the Bar instance lifecycle. What is the correct way of doing it?  </p>
  
  <p>In fact, I thought I could write like the code below but it does not compile..</p>
  
  <pre><code>class Foo;
  
  class Bar {
  public:
      Foo * const foo;
      Bar(Foo* foo) {
          this-&gt;foo = foo;
      }
  };
  
  class Foo {
  public:
    int a;
  };
  </code></pre>
  
  <p>Any suggestion is welcome.</p>