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

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.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.