I have some problems to compile this code. I cannot find out the mistakes. The error is not because of the scope or the constant function. I also tried to put the sort method in a non-constant function and the same error occurred.
struct _Invoice {
unsigned int amm;
string id;
};
.
.
.
vector<_Invoice> Invoices;
.
.
.
bool invComp(const _Invoice &a, const _Invoice &b){
return a.amm < b.amm;
}
unsigned int MedianInvoice ( void ) const{
vector<_Invoice>tmpInvoices(Invoices);
sort(tmpInvoices.begin(), tmpInvoices.end(), invComp);
return (tmpInvoices.begin() + ceil((double)tmpInvoices.size() / 2))->amm;
}
Thanks in advance!