The verb 姓 (xìng) literally means "to be surnamed" or "to have the surname." You can use 姓 to tell someone your own surname, or that of someone else.
Giving One’s Surname
Subject + 姓 + Surname
我 姓 王。
Asking Someone’s Surname
You can also use 姓 to ask people their surnames. You could do this quite directly by saying:
你 姓 什么 ?
However, the polite way to ask has a set form:
您 贵 姓 ？
Literally this means "What is your honourable surname?" Use this form to be polite when asking people their surnames.
What is your honourable surname?