Use std::pair for storing name and val instead of using struct node by using this you need not define the ‘<’ or ‘>’ operator for node.
If you want the pair with the smallest value of val, you need a min priority queue or priority queue in the opposite case.
How to use std::priority_queue in this case ?
priority_queue< pair< int, string > , vector< pair< int, string> >, greater< pair< int, string > > > pq;
// assuming name is of type std::string
Pushing an element in pq :
int value;
string name;
cin >> value >> name;
pq.push(make_pair(value, name));
Extracting the minimum value and the name corresponding to that value :
pair< int, string > p = pq.top();
cout << "Minimum value is : " << p.first;
cout << "Name corresponding to " << p.first << " is " << p.second;
For more information about std::priority_queue refer this.
For now u can consider min heap implem. as syntax for pq with min heap,
Basically we are passing container type,comparision function as a parameter to a pq stl.