parser error void not a void

the following method
(declared void in the header)

is giving me the following error on the line
"currentPass = purchasedPasses.pop_back();"


error: void value not ignored as it ought to be

there's not a return anywhere in that code ...i simply do NOT get it??

[or i need another coffee]

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
void MyTic::AddJourney(Journey* newJourney)
{
//get currentTravelPass
TravelPass* currentPass;

if (purchasedPasses.size() >0)
{
currentPass = purchasedPasses.pop_back();
}
else
{
//create new lowest value pass
//presumes no trip is longer than 2 Hours
currentPass = TravelPass(twoHourLength, newJourney->highestZone);
}


}
pop_back does not return the last element, it simply removes it. (the reason it does this is for exception safety).

What you want to do is this:

1
2
currentPass = purchasedPasses.back();  // get the last element
purchasedPasses.pop_back(); // then drop it 
thanks:

Just came to type the same thing

8)
Topic archived. No new replies allowed.