Skip to main content
The tag `vector` has been replaced by the more specific tag `stdvector`.
Link
edited tags
Link
Jonas
  • 130.5k
  • 103
  • 330
  • 408
added 3 characters in body
Source Link
Micha Wiedenmann
  • 21.1k
  • 22
  • 96
  • 142

When I do this:

std::vector<int> hello; 

Everything works great. However, when I make it a vector of references instead:

std::vector<int &> hello; 

I get horrible errors like "error C2528: 'pointer' : pointer to reference is illegal".

error C2528: 'pointer' : pointer to reference is illegal

I want to put a bunch of references to structs into a vector, so that I don't have to meddle with pointers. Why is vector throwing a tantrum about this? Is my only option to use a vector of pointers instead?

When I do this:

std::vector<int> hello; 

Everything works great. However, when I make it a vector of references instead:

std::vector<int &> hello; 

I get horrible errors like "error C2528: 'pointer' : pointer to reference is illegal".

I want to put a bunch of references to structs into a vector, so that I don't have to meddle with pointers. Why is vector throwing a tantrum about this? Is my only option to use a vector of pointers instead?

When I do this:

std::vector<int> hello; 

Everything works great. However, when I make it a vector of references instead:

std::vector<int &> hello; 

I get horrible errors like

error C2528: 'pointer' : pointer to reference is illegal

I want to put a bunch of references to structs into a vector, so that I don't have to meddle with pointers. Why is vector throwing a tantrum about this? Is my only option to use a vector of pointers instead?

add relevant tags
Link
underscore_d
  • 6.9k
  • 4
  • 46
  • 75
Loading
deleted 7 characters in body
Source Link
Violet Giraffe
  • 33.8k
  • 56
  • 212
  • 366
Loading
correction in body; error happens when switching to reference not vector; it is vector in both cases
Source Link
Agnel Kurian
  • 59.9k
  • 47
  • 158
  • 228
Loading
Source Link
Colen
  • 14k
  • 21
  • 84
  • 109
Loading