vector
stores elements in memory space continuously just like an array
All you have to do is point at the vector with the pointer
Please write as follows
int main(){
std::vector<double> v;
v.push_back(3.14);
v.push_back(5.16);
double* a = &v[0]; // Like this
for (int i=0; i<2; i++) {
cout << a[i] << endl;
}
}
© 2024 OneMinuteCode. All rights reserved.