In the call:
cout << "Private = " << object1.getPVT() << endl;
You are calling the
public
method
getPVT
which returns the value of the
private
variable. In the second program (I assume) you are trying to access the
private
variable
pvt
directly, which is not allowed.