title: Address of an object in c++ and its members
body: <p>I am working on one of my application issue.
  Here the problem i am facing is there are some bunch of function which i need to call using the pointer of a class object.</p>
  
  <p>But the main problem is i donot have a class pointer with me,instead i have a member variable value(lets say its a list of values). following this i did a small test with the below code.</p>
  
  <pre><code>using namespace std;
  
  class Person {
  public:
        Person(string name, int age) {
              this-&gt;name = name;
              this-&gt;age = age;
        }
        string getName() {
              return name;
        }
        int getAge() {
              return age;
        }
        void Print()
        {
        printf("This address is %x\n",this);
        printf("age adress is %x\n",&amp;age);
  
        }
  private:
        int age;
        string name;
  
  };
  
  int main() {
        cout &lt;&lt; "Creating a person..." &lt;&lt; endl;
  
  Person *johnDoe=new Person("John Doe", 25);
        cout &lt;&lt; "Person's name: " &lt;&lt; johnDoe-&gt;getName() &lt;&lt; endl;
        cout &lt;&lt; "Person's age: " &lt;&lt; johnDoe-&gt;getAge() &lt;&lt; endl;
        johnDoe-&gt;Print();
        delete johnDoe;
        return 0;
  }
  </code></pre>
  
  <p>The coutput of the execution is :</p>
  
  <pre><code>&gt; ./a.out
  Creating a person...
  Person's name: John Doe
  Person's age: 25
  This address is 72918
  age adress is 72918
  </code></pre>
  
  <p>Now my doubt is :</p>
  
  <p>Is it guaranteed that the address of the class member variable always points to the address of the object?
  Can i use this address in case i need to use the pointer for calling other core api functions?</p>
  
  <p>I saw this when i googled?</p>
  
  <p><em>(C1x §6.7.2.1.13: "A pointer to a structure object, suitably converted, points to its initial member ... and vice versa. There may be unnamed padding within as structure object, but not at its beginning.")</em></p>
  
  <p>is this true even in case of c++ and classes?</p>