| | |
Help with a vector<vector<string> *>
Please support our C++ advertiser: Intel Parallel Studio Home
Thread Solved |
•
•
Join Date: Jul 2009
Posts: 5
Reputation:
Solved Threads: 0
Hi, for a class, I'm trying to implement a separate-chaining hash table stored in a vector that contains pointers to vectors where the keys will be stored. This is basically what I have:
The problem I'm having is when I want to access the keys in the KeyChain, I don't know how to get to those values, this is what I've tried:
What is the syntax for accessing the items in a vector that is referenced with a pointer in another vector? Thank you for your help!
c++ Syntax (Toggle Plain Text)
typedef vector<string> KeyChain; vector<KeyChain *> Table;
The problem I'm having is when I want to access the keys in the KeyChain, I don't know how to get to those values, this is what I've tried:
c++ Syntax (Toggle Plain Text)
Table[value][index] Table[value]->[index]
What is the syntax for accessing the items in a vector that is referenced with a pointer in another vector? Thank you for your help!
Failure is not fatal, but failure to change might be. - John Wooden
•
•
Join Date: Jul 2009
Posts: 5
Reputation:
Solved Threads: 0
Thank you, that works, but I also asked my instructor about it, and he told me that he wanted us to do something along these lines:
So I'll be doing that, but thanks for the help!
c++ Syntax (Toggle Plain Text)
vector<string> *Table; Table = new vector<string>[size];
So I'll be doing that, but thanks for the help!
So, where is a problem?
C++ Syntax (Toggle Plain Text)
vector<string> *Table; Table = new vector<string>[2]; Table[0].push_back("Aaa"); Table[0].push_back("Bbb"); Table[0].push_back("Ccc"); Table[1].push_back("Ppp"); Table[1].push_back("Qqq"); cout << "\n" << Table[0][0]; cout << "\n" << Table[0][1]; cout << "\n" << Table[0][2]; cout << "\n" << Table[1][0]; cout << "\n" << Table[1][1]; Table[0][0]="AAAAAA"; ....
Failure is not fatal, but failure to change might be. - John Wooden
![]() |
Similar Threads
- string to vector<string> and splitting a string. Need help! (C++)
- Copy Contents of One 2d Vector to Another 2d Vector (C++)
- vector of string (C)
- problem implementing BFS using string vector (C++)
- copying string from a vector to another (C++)
- how can i use an iterator for a 2d vector? (C++)
- Array required, but java.lang.String and java.util.Vector found (Java)
- Vector of strings (warnings) ? ? (C++)
Other Threads in the C++ Forum
- Previous Thread: simple code not working
- Next Thread: Save function not working
| Thread Tools | Search this Thread |
api array beginner binary bitmap c++ c/c++ calculator char char* class classes coding compile compiler console conversion count data database delete desktop developer directshow dll download dynamic email encryption error file forms fstream function functions game getline google graph gui homeworkhelper iamthwee ifstream input int integer java lib linkedlist linker linux loop looping loops map math matrix memory multiple news node number numbertoword output parameter pointer problem program programming project proxy python random read recursion recursive reference return rpg sorting string strings struct template templates test text text-file tree unix url vector video visualstudio win32 windows winsock word wordfrequency wxwidgets






