string apple = "Hello"; // initialization
apple = "Dolly"; // assignment
pear = apple; // copy assignment
std::cin >> apple; // from input stream
A string is text. When is one word less than an another word?
Sorting words to lexicographical order uses the 'less than'.
String has relational operators. Hence this is valid:
1 2 3
if ( pear < apple ) {
std::cout << apple;
}
However, you do mention value as in a number?
In other words you have a word and you want to associate a number with it?
You could define and use a struct:
1 2 3 4 5 6 7 8 9 10 11
struct Data {
std::string name {};
int count {};
};
Data apple { "Dolly", 5 };
Data pear;
if ( pear.count < apple.count ) {
std::cout << apple.name;
}