943,598 Members | Top Members by Rank

Ad:
  • C++ Discussion Thread
  • Unsolved
  • Views: 640
  • C++ RSS
Aug 6th, 2009
0

vector pointers

Expand Post »
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?
C++ Syntax (Toggle Plain Text)
  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?
Reputation Points: 10
Solved Threads: 0
Junior Poster in Training
JackDurden is offline Offline
92 posts
since Jun 2008
Aug 6th, 2009
0

Re: vector pointers

create a vectors of char*, then in a for loop, have char* pointing
to a different vectors.
Reputation Points: 840
Solved Threads: 594
Senior Poster
firstPerson is offline Offline
3,862 posts
since Dec 2008
Aug 6th, 2009
0

Re: vector pointers

Also, you could use boost or ptr_vector.
Reputation Points: 10
Solved Threads: 3
Newbie Poster
Asafe is offline Offline
24 posts
since Jul 2009
Aug 6th, 2009
0

Re: vector pointers

Why not just a vector of vectors?
Reputation Points: 888
Solved Threads: 114
Nearly a Posting Virtuoso
MosaicFuneral is offline Offline
1,270 posts
since Nov 2008
Aug 6th, 2009
0

Re: vector pointers

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'?

C++ Syntax (Toggle Plain Text)
  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. }
Featured Poster
Reputation Points: 437
Solved Threads: 204
Posting Virtuoso
daviddoria is offline Offline
1,968 posts
since Feb 2008

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in C++ Forum Timeline: HTTP Request in C++ & wt web toolkit
Next Thread in C++ Forum Timeline: Copying Files With C++





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC