Accessing the private data inside main function
<p>Inside main.cpp</p>

<pre><code>class vivek
{
    int i;
    float d;
public:
    vivek()
    {
        i = 4;
        d = 4.44;
    }
    ~vivek()
    {
        cout &lt;&lt; "destructor" &lt;&lt; i;
    }
    int get()
    {
        return i;
    }
};

int main()
{
    vivek *viku = new vivek;
    vivek *p;

    p = viku;
    cout &lt;&lt; (*(int*) (p));
    getchar();

    return 0;
}
</code></pre>

<p>Through above code i can able to access variable i , but i want to know how can i access the variable d .</p>

<p>I know this concept shall not be advisable since it violates encapsulation .. But i just want to know how we can do this ?</p>
