Pointer to a vector

I am trying to make a pointer to a vector in order to be able to easily choose from a few different vectors for a non recursive towers of hanoi homework assignment I have. I have been looking all of the internet and trying to find a syntax that works, but so far the closest thing I have gives me an error that I cannot convert a vector pointer to a vector pointer.

Can anyone tell me what the proper syntax is or if it's even possible to do what I want to do?

Thanks in advance
Your question is not exact. What do you mean by "pointer to a vector"?

Something like this?
1
2
typedef vector <int> ints_t;
ints_t* i_am_a_pointer_to_a_vector;
something like

1
2
vector<int> A, B, C;
vector<int>::pointer X = A


I want to be able to make X equal to any one of the first vectors.
Wait... then you mean a pointer to an element in a vector?

-Albatross
No, I want the X to be able to access any element in the other vectors.
Please pay attention. You cannot learn anything unless you actually try some of the suggestions we give you.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#include <iostream>
#include <vector>
using namespace std;

void print( vector <int> * v )
  {
  for (unsigned n = 0; n < v->size(); n++)
    cout << v->at( n ) << " ";
  cout << endl;
  }

int main()
  {
  int _primes[]     = { 2, 3, 5, 7 };
  int _fibonaccis[] = { 1, 1, 2, 3 };

  vector <int> primes(     _primes,     _primes     + 4 );
  vector <int> fibonaccis( _fibonaccis, _fibonaccis + 4 );

  print( &primes );
  print( &fibonaccis );

  return 0;
  }

Hope this helps.
Topic archived. No new replies allowed.