(1) Within the rules: No. Private data is private data and the whole point is that you _can't_ access it unless you're a member function or a friend.
(2) Outside the rules: Yes. Just find the pointer to the object, work out the offset of h within the object and add that offset in bytes to the pointer, cast it to an int* and dereference the pointer.
Code:
struct emp
{
private:
int h;
public:
void setdata(int a)
{
h = a;
}
}emp1;
void hackemp()
{
emp1.setdata(5);
int *foo=(int*)&emp1;
// Assume offset of h is zero as it's the first thing in the class
printf("emp1.h=%d\n",*foo);
// Just to prove we're not cheating
emp1.setdata(10);
printf("emp1.h=%d\n",*foo);
}
Output:
emp1.h=5
emp1.h=10