Class data member access through outside function

Write a program to declare data member of a class, and use member function to access it, function definition should be outside of a class.

#include<iostream>
using namespace std;
class A
{
	private:
		int x,y;
	public:
		void setdata();
		void print();
};
void A :: setdata()
{
	cout << "Enter values of x and y = ";
	cin >> x >> y;
}
void A :: print()
{
	cout << "x = " << x << " y = " << y << endl;
}
int main()
{
	A obj;
	obj.setdata();
	obj.print();
	return 0;
}

Output

Enter value of x and y = 10 20
x = 10 y = 20