title: How to return a const ref to a struct object such that all its nested structures also are read only?
body: <p>How do I prevent all the member variables in a nested struct to be non modifiable?</p>
  
  <pre><code>typedef struct A  
  {  
      int a;  
      int b;  
  }A1;  
  
  typedef struct B  
  {  
      A1* objA;  
  }B1;  
  
  class C  
  {  
  public:  
      const B&amp; GetB() const { return objB; }  
      PopulateB();  
  
  private:  
      B objB;  
  };  
  
  int main()  
  {  
      C objC;
      objC.PopulateB();  
      const B&amp; objB2 = objC.GetB();  
      objB2.objA-&gt;a = 3; // compiler allows this  
  }  
  </code></pre>
  
  <p>I just want a struct that is completely read only and I expected this to work. (In this case objB2)</p>