Passing reference of an object to function gives error
Mar 22, 2020 at 12:12am UTC
Hello, I am currently trying to pass a reference to an object to a function.
First I get a reference to the vector that stores it
vector <Bbox>& bbox_container = scene->getBboxContainer();
Then I proceed to call the method that has this declaration:
void intersect (Vec3f& camera_dir, Vec3f& camera_ori, Vec3f& dist, Vec3f& s2, Bbox& s, float & v, int x, int y);
and I try to do so with this function call
if (bbox_container[i].intersect (camera_dir,camera_ori,dist_ori[i],s2_ori[i],bbox_container[i],t,x,y))
and this line generates this massive error message:
|249|error: could not convert ‘((Bbox*)((std::vector<Bbox, std::allocator<Bbox> >*)bbox_container)->std::vector<_Tp, _Alloc>::operator [] [with _Tp = Bbox, _Alloc = std::allocator<Bbox>](((long unsigned int )i)))->Bbox::intersect(((Vec3f&)(& camera_dir)), ((Vec3f&)(& camera_ori)), ((Vec3f&)(dist_ori + ((long unsigned int )(((long unsigned int )i) * 12ul)))), ((Vec3f&)(s2_ori + ((long unsigned int )(((long unsigned int )i) * 12ul)))), ((Bbox&)((Bbox*)((std::vector<Bbox, std::allocator<Bbox> >*)bbox_container)->std::vector<_Tp, _Alloc>::operator [] [with _Tp = Bbox, _Alloc = std::allocator<Bbox>](((long unsigned int )i)))), ((float &)(& t)), x, y)’ to ‘bool ’|
I honestly do not know what it is trying to tell. All I can tell is that a similar code, where the vector of a certain object is replaced by a dynamic array of it works.
So I will appreciate any suggestions.
Last edited on Mar 22, 2020 at 12:14am UTC
Mar 22, 2020 at 12:58am UTC
Are you sure that's the full error line? You're missing a ' for a start.
It would also help if you posted the definitions of dist_ori
and s2_ori
.
Mar 22, 2020 at 1:11am UTC
error: could not convert ‘something’ to ‘bool’
Like in:
1 2 3
void intersect();
if ( intersect() ) // error: how to make bool from void?
Topic archived. No new replies allowed.