Question

create an example using dictionaries in c++ please in c++ oop and include .h .cpp all...

create an example using dictionaries in c++ please in c++ oop and include .h .cpp all files thnx?

Homework Answers

Answer #1

IF YOU LIKE THE ANSWER PLEASE UPVOTE RATHER THAN DOWNVOTE.

ANY QUESTION PLEASE DO ASK WILL BE HAPPY TO HELP YOU.

From your i could only understand is this you need a dictionary to be implemented in C++ which i have done and sharing with you. Do have a look and let me know if anything else needed.

there is only one .cpp file required which you can create with any name and paste your code it will run.

std::map is the standard library which is used to implement dictionary in c++. It uses key value pair where keys are unique and values are associated with them map is STL in C++.

#include <string>
// Map is the concept through which we implement dictionary in C++, So including the header files.
#include <map>
#include <iostream>
using namespace std;

int main()
{
   // creating the map with key and value pair
   // Like in dictionary we have meaning for word here for a particluar key we have a value.
   map<int, string> m;
   m[1] = "A";
   m[2] = "B";
   m[3] = "C";
   m[4] = "D";
   m[5] = "E";
   m[6] = "F";

   // Loop through and print elements from map
   for (auto i : m)
   {
       cout << i.first << " : " << i.second << endl;
   }

   // Fetching the value based on key
   cout << "The value for key 1 is : " << m[1] << endl;

   // Inserting a key at end.
   m[7] = "9";
   // Modifying the existing key and changing the value from C to Z
   m[3] = "Z";

   // Loop through and print elements from map
   for (auto i : m)
   {
       cout << i.first << " : " << i.second << endl;
   }

  
return 0;
}

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
How to create the multiple class in Java? Please elaborate it by using the example.
How to create the multiple class in Java? Please elaborate it by using the example.
Using butane, 1-bromobutane or 2-bromobutane, create 3 methylheptane. Please include steps.
Using butane, 1-bromobutane or 2-bromobutane, create 3 methylheptane. Please include steps.
C++ question. Must use #include <iostream> and "using namespace std;" You must also have only a...
C++ question. Must use #include <iostream> and "using namespace std;" You must also have only a .cpp and .h file Define a class called Rectangle that can store the height and width of a rectangle as instance variables, has a constructor that allows you to set the height and width when you create a Rectangle, a default constructor that sets both height and width to 0, and functions to return the following values: * the perimeter [ which should be...
Create shell scripts, each in its own .sh file. Please include a shebang line at the...
Create shell scripts, each in its own .sh file. Please include a shebang line at the top of the script as well as appropriate comments through out. Write a script that uses sed to replace all instances of the name "Lizzy" with "Elizabeth" in a text file. Save the updated text in a new file named after the original text file with "-formal" appended before the file extension, e.g. old.txt -> old-formal.txt. Test this script on the data-shell/writing/data text files....
Create a class called Student. Include the following instance variables: name, address, phone, gpa Create all...
Create a class called Student. Include the following instance variables: name, address, phone, gpa Create all of the methods required for a standard user defined class: constructors, accessors, mutators, toString, equals Create the client for testing the Student class (5 points extra credit) Create another class called CourseSection (20 points extra credit) Include instance variables for: course name, days and times course meets (String), description of course, student a, student b, student c (all of type Student) Create all of...
Using C++ code, write a program named q5.cpp to solve the equation 2n = 14.27 for...
Using C++ code, write a program named q5.cpp to solve the equation 2n = 14.27 for n.
Please answer in C++ with the correct files (in bold). Thanks! Write a program that creates...
Please answer in C++ with the correct files (in bold). Thanks! Write a program that creates three identical arrays, list1, list2, and list3, of 5000 elements. The program then sorts list1 using bubble sort, list2 using selection sort, and list3 using insertion sort and outputs the number of comparisons and item assignments made by each sorting algorithm. Please use the file names listed below since your file will have the following components: Ch18_Ex15.cpp searchSortAlgorithms.h
Please write code in C++ and include all header files not including std/bitsc: (Maximum consecutive increasingly...
Please write code in C++ and include all header files not including std/bitsc: (Maximum consecutive increasingly ordered substring) Write a program that prompts the user to enter a string and displays the maximum consecutive increasingly ordered substring. Analyze the time complexity of your program. Sample Run 1 Enter a string: abcabcdgabxy The maximum consecutive increasing ordered substring is abcdg Sample Run 2 Enter a string: abcabcdgabmnsxy The maximum consecutive increasing ordered substring is abmnsxy
How to convert kmol/h to kg/h? Please show me that by an example etc.
How to convert kmol/h to kg/h? Please show me that by an example etc.
Create a C++ project. Download and add the attached .h and .cpp to the project. Write...
Create a C++ project. Download and add the attached .h and .cpp to the project. Write an implementation file to implement the namespace declared in the attached CSCI361Proj5.h. Name the implementation file as YourNameProj5.cpp and add it to the project. Run the project to see your grade. .h file: // Provided by: ____________(your name here)__________ // Email Address: ____________(your email address here)________ // FILE: link.h // PROVIDES: A toolkit of 14 functions for manipulating linked lists. Each // node of...