title: C++: syntax for accessing member struct from pointer to class
body: <p>I'm trying to access a member structs variables, but I can't seem to get the syntax right. 
  The two compile errors pr. access are:
  error C2274: 'function-style cast' : illegal as right side of '.' operator
  error C2228: left of '.otherdata' must have class/struct/union
  I have tried various changes, but none successful.</p>
  
  <pre><code>#include &lt;iostream&gt;
  
  using std::cout;
  
  class Foo{
  public:
      struct Bar{
          int otherdata;
      };
      int somedata;
  };
  
  int main(){
      Foo foo;
      foo.Bar.otherdata = 5;
  
      cout &lt;&lt; foo.Bar.otherdata;
  
      return 0;
  }
  </code></pre>