0

I have a function:
void CreateCostGrid(vector<ScanPoint> &Data, int whichcol, vector<LiDARScan> &LiDARGrid);

That I call like this:
CreateCostGrid(TestScan.getColumn(GoodCols.at(testcol)), GoodCols.at(testcol), ModelScans);

But I get this:
error: initial value of reference to non-const must be an lvalue
CreateCostGrid(TestScan.getColumn(GoodCols.at(testcol)), GoodCols.at(testcol), ModelScans);
(There is an arrow underneath the T in TestScan, i guess indicating that is there the problem is?)

This has been working for weeks and all of a sudden stopped working - so there is nothing wrong with any of the things you can't see here (ie. the ScanPoint class or the LiDARScan class).

Anyone know what this error means?

Thanks,

Dave

2
Contributors
1
Reply
2
Views
8 Years
Discussion Span
Last Post by Duoas
0

It is because you are trying to pass a temporary object to the function. Temps are const. Therefore your function header should be: void CreateCostGrid(const vector<ScanPoint> &Data, int whichcol, vector<LiDARScan> &LiDARGrid); If you want to modify the data, then your getColumn() function must return a non-const reference. vector<ScanPoint>& getColumn(...); Hope this helps.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.