I'm sure this question exists somewhere on this site, but I guess I'm not too sure what to search because I haven't found my answer yet. So I apolgoize if I am posting a duplicate.
Anyway, I am trying to create a vector of pointers that point to a vectors.
Here is what I have so far:
float knot_vector1[] = {-1,-1,-1 0,1,1,1}; float knot_vector2[] = {-1, -1, 1, 1}; float knot_vector3[] = {-1, -1, -1, -1, 0, .5, .5, .5, 1, 1, 1, 1}; // initialize vectors with the arrays defined above vector<float> U1 (knot_vector1, knot_vector1 + sizeof(knot_vector1) / sizeof(knot_vector1[0]) ); vector<float> U2 (knot_vector2, knot_vector2 + sizeof(knot_vector2) / sizeof(knot_vector2[0]) ); vector<float> U3 (knot_vector3, knot_vector3 + sizeof(knot_vector3) / sizeof(knot_vector3[0]) ); vector<float> *ptr_u1 = &U1; // creating pointers that point to my vectors vector<float> *ptr_u2 = &U2; vector<float> *ptr_u3 = &U3; vector<vector<float>*> knotvectors[] = {ptr_u1, ptr_u2, ptr_u3}; Here is the error I receive:
error: conversion from 'std::vector<float>*' to non-scalar type 'std::vector<std::vector<float>*>' requested| So obviously something is wrong with the last line where I define my vector of pointers. What is the proper way to do this?
Thank you in advance.
*ptr_u2 = &U2and*ptr_u3 = &U3, notU1all 3 times?[]from thevector<vector>declaration as you are then declaring an array ofvector<vector>.{&U1, &U2, &U3}: you don't need to declare intermediate pointers just to put them into the vector.