title: accessing member of structure within a class
body: <p>I have an .hpp and .cpp file. I want to access the variable in the structure within a class which happens to be in the header .hpp file, in the .cpp file. </p>
  
  <p>In .hpp, I have</p>
  
  <pre><code>class foo{
  
  public:
         struct packet{
           int x;
           u_int y;
        };
  
  };
  
   foo(const char*name)
  :m_name(name){}
  </code></pre>
  
  <p>In .cpp I did:</p>
  
  <pre><code>foo *foo_1 = &amp;foo;
  printf("The value of x is : %d",foo_1-&gt;packet.x);
  printf ("The value of y is : %u", foo_1-&gt;packet.y);
  </code></pre>
  
  <p>On doing this I receive the following error:</p>
  
  <pre><code>code_1.cpp:117: error: expected primary-expression before ‘;’ token
  code_1.cpp:118: error: invalid use of ‘struct foo::packet’
  code_1.cpp:119: error: invalid use of ‘struct foo::packet’
  make: *** [code_1] Error 1
  </code></pre>
  
  <p>My objective is to get the values of x and y in the cpp file. Any suggestion/idea will be really appreciated.</p>
  
  <p>Thanks.</p>