Help with a vector<vector<string> *>

Thread Solved
Reply

Join Date: Jul 2009
Posts: 5
Reputation: squall1986 is an unknown quantity at this point 
Solved Threads: 0
squall1986 squall1986 is offline Offline
Newbie Poster

Help with a vector<vector<string> *>

 
1
  #1
Jul 4th, 2009
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:

  1. typedef vector<string> KeyChain;
  2. 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:
  1. Table[value][index]
  2. 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!
Reply With Quote Quick reply to this message  
Join Date: Oct 2008
Posts: 2,431
Reputation: adatapost has much to be proud of adatapost has much to be proud of adatapost has much to be proud of adatapost has much to be proud of adatapost has much to be proud of adatapost has much to be proud of adatapost has much to be proud of adatapost has much to be proud of adatapost has much to be proud of adatapost has much to be proud of 
Solved Threads: 437
adatapost's Avatar
adatapost adatapost is online now Online
Nearly a Posting Maven

Re: Help with a vector<vector<string> *>

 
0
  #2
Jul 4th, 2009
Welcome squall1986,

Use may use :
  1. (*(Table[index]))[index];
Failure is not fatal, but failure to change might be. - John Wooden
Reply With Quote Quick reply to this message  
Join Date: Jul 2009
Posts: 5
Reputation: squall1986 is an unknown quantity at this point 
Solved Threads: 0
squall1986 squall1986 is offline Offline
Newbie Poster

Re: Help with a vector<vector<string> *>

 
0
  #3
Jul 5th, 2009
Originally Posted by adatapost View Post
Welcome squall1986,

Use may use :
  1. (*(Table[index]))[index];
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:

  1. vector<string> *Table;
  2. Table = new vector<string>[size];

So I'll be doing that, but thanks for the help!
Reply With Quote Quick reply to this message  
Join Date: Oct 2008
Posts: 2,431
Reputation: adatapost has much to be proud of adatapost has much to be proud of adatapost has much to be proud of adatapost has much to be proud of adatapost has much to be proud of adatapost has much to be proud of adatapost has much to be proud of adatapost has much to be proud of adatapost has much to be proud of adatapost has much to be proud of 
Solved Threads: 437
adatapost's Avatar
adatapost adatapost is online now Online
Nearly a Posting Maven

Re: Help with a vector<vector<string> *>

 
0
  #4
Jul 5th, 2009
So, where is a problem?
  1. vector<string> *Table;
  2. Table = new vector<string>[2];
  3.  
  4. Table[0].push_back("Aaa");
  5. Table[0].push_back("Bbb");
  6. Table[0].push_back("Ccc");
  7.  
  8. Table[1].push_back("Ppp");
  9. Table[1].push_back("Qqq");
  10.  
  11. cout << "\n" << Table[0][0];
  12. cout << "\n" << Table[0][1];
  13. cout << "\n" << Table[0][2];
  14. cout << "\n" << Table[1][0];
  15. cout << "\n" << Table[1][1];
  16. Table[0][0]="AAAAAA";
  17. ....
Failure is not fatal, but failure to change might be. - John Wooden
Reply With Quote Quick reply to this message  
Join Date: Jul 2009
Posts: 5
Reputation: squall1986 is an unknown quantity at this point 
Solved Threads: 0
squall1986 squall1986 is offline Offline
Newbie Poster

Re: Help with a vector<vector<string> *>

 
0
  #5
Jul 5th, 2009
Originally Posted by adatapost View Post
So, where is a problem?
Umm ... I don't think there is a problem now, it's working fine for me. Are you asking me that because you see one and you want me to look for it ... ?
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC