vector pointers

Please support our C++ advertiser: Intel Parallel Studio Home
Reply

Join Date: Jun 2008
Posts: 92
Reputation: JackDurden is an unknown quantity at this point 
Solved Threads: 0
JackDurden JackDurden is offline Offline
Junior Poster in Training

vector pointers

 
0
  #1
Aug 6th, 2009
I have a vector which i wish to fill with char's, so that each char is then a pointer to a vector.

vector<char> list;

list[0] = 'A';
list[1] = 'B';

How do I make 'A' and 'B' pointers to other vectors?
  1. void Create_Pointers(char pointer_name)
  2. {
  3. pointer_name = new vector<char *>;
  4. list.push_back(pointer_name);
  5.  
  6. }

would pointer_name have to be declared as a pointer?
Reply With Quote Quick reply to this message  
Join Date: Dec 2008
Posts: 1,435
Reputation: firstPerson is just really nice firstPerson is just really nice firstPerson is just really nice firstPerson is just really nice firstPerson is just really nice 
Solved Threads: 186
firstPerson's Avatar
firstPerson firstPerson is offline Offline
Nearly a Posting Virtuoso

Re: vector pointers

 
0
  #2
Aug 6th, 2009
create a vectors of char*, then in a for loop, have char* pointing
to a different vectors.
Reply With Quote Quick reply to this message  
Join Date: Jul 2009
Posts: 24
Reputation: Asafe is an unknown quantity at this point 
Solved Threads: 3
Asafe's Avatar
Asafe Asafe is offline Offline
Light Poster

Re: vector pointers

 
0
  #3
Aug 6th, 2009
Also, you could use boost or ptr_vector.
Always code as if your client were a maniac seriall killer who knows where you live.
Reply With Quote Quick reply to this message  
Join Date: Nov 2008
Posts: 977
Reputation: MosaicFuneral is just really nice MosaicFuneral is just really nice MosaicFuneral is just really nice MosaicFuneral is just really nice MosaicFuneral is just really nice 
Solved Threads: 92
MosaicFuneral's Avatar
MosaicFuneral MosaicFuneral is offline Offline
Posting Shark

Re: vector pointers

 
0
  #4
Aug 6th, 2009
Why not just a vector of vectors?
"Jedenfalls bin ich überzeugt, daß der Alte nicht würfelt."
"I became very sensitive to what will happen to all this and all of us." -Two geniuses named Albert
Reply With Quote Quick reply to this message  
Join Date: Feb 2008
Posts: 638
Reputation: daviddoria is a jewel in the rough daviddoria is a jewel in the rough daviddoria is a jewel in the rough 
Solved Threads: 46
daviddoria daviddoria is offline Offline
Practically a Master Poster

Re: vector pointers

 
0
  #5
Aug 6th, 2009
In that sample code, pointer_name should really be vector_name, no? And pointer_name should be of type std::vector<std::vector<<char *> >, no? And what is 'list'?

  1. void Create_Pointers(std::vector<std::vector<char *> > pointer_name)
  2. {
  3. std::vector<char *> NewVector;
  4. pointer_name.push_back(NewVector);
  5.  
  6. }
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



Tag cloud for C++
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC