#include#include #include int main() { QHash hash; // Insert key-value pairs hash.insert("apple", 5); hash.insert("banana", 3); // Retrieve values int appleValue = hash.value("apple"); int bananaValue = hash.value("banana"); std::cout << "Apple value: " << appleValue << std::endl; std::cout << "Banana value: " << bananaValue << std::endl; return 0; }
#include#include #include int main() { QHash hash; // Insert key-value pairs hash.insert("apple", 5); hash.insert("banana", 3); // Iterate through the hash QHash ::const_iterator i; for (i = hash.constBegin(); i != hash.constEnd(); ++i) { std::cout << i.key().toStdString() << ": " << i.value() << std::endl; } return 0; }
#includeQHash belongs to the Qt library, which is a cross-platform application framework for desktop and mobile application development. It provides a comprehensive set of libraries and tools for developing graphical user interfaces, network connections, multimedia applications, and more.#include #include int main() { QHash hash; // Insert key-value pairs hash.insert("apple", 5); hash.insert("banana", 3); // Remove a value hash.remove("apple"); // Check if value exists bool hasApple = hash.contains("apple"); std::cout << "Has apple: " << hasApple << std::endl; return 0; }