Let's look at the context of STIV. Whatever he had, if anything, it would have been able to use to buy a pie in the 2oth Century. It's just like if you or I were in Sidney, holding dollars or euros, we couldn't buy a pie, or beer, or or anything.
Won't work, as Kirk specifically said he/they didn't have/use money
in the future.
Kirk might have been lying, to make himself look less cheap in front of the lady. Or he might have been broke in the 23rd century, perhaps because Starfleet confiscates the accounts of mutineers. Or he might have had money, but he couldn't fathom the idea of using money to pay for food, which is free where he comes from. But he most definitely wasn't saying "Yeah, I got shitloads of it, but it's of no use in paying for this pizza".
And whatever Jake was saying, he was doing it in the role of a Federation citizen, albeit admittedly a junior one. His exact words were "I'm human, I don't have any money", with the first part an obvious justification for the second part. As Jake extrapolates, "We work to better ourselves and the rest of humanity. It means... it means we don't need money."
So while the writers were having fun with the ill-defined idea of a moneyless humanity (and possibly moneyless Federation), they also set the concept in stone at long last. Pretty much how the joke about changing Klingon foreheads in "Trials and Tribble-ations" canonized the concept that the foreheads indeed had changed.
Sorry about being semi-serious about this, but it does look as if money goes extinct in the 24th century, and already is of limited worth in the late 23rd (even though buying and selling still explicitly happens). There's no doubt a lot of finesse to this in-universe, and a lot of ambiguity in terms of what is actually written and shot, and plenty of tongues in plenty of cheeks - but it's still a confirmed feature of the Star Trek future.
The bottom line here is, yeah, our future heroes have money or something similar to it when the plot calls for it (probably Starfleet expense accounts), but they also always lack money when it comes to doing a common 20th century style purchase, for greater dramatic or comical effect. And buying the services of a prostitute would probably fall under the latter category...
As for Bashir and O'Brien, we'll never know if they just flew fighters in their Battle of Britain simulation, or in addition they would occasionally get lucky with holographic RAF nurses, or whether they had Dabo girls dress up like RAF nurses.
Oh, I see the services of a holographic Hun who dies in the cockpit of his Messerschmitt meeting the criteria of prostitution just as much as the services of a holographic nurse who opens her legs to the heroic pilot. The holo-Kraut fulfills a carnal fantasy by lending out his body for Bashir to exploit, probably in a more tangibly and conventionally erotic fashion than some fetish pro of today. There must be plenty of more far-out types of "sexual" services out there in the 24th century Federation than playing a Nazi target to the sadistic lust of a wannabe Briton.
That's what I meant by the idea of the 24th century folks failing to recognize the concept of prostitution. Every profession involving offering a body for hire is whoring when one gets down to it. Today, we have the most obvious whores in the broadcast arts and in sports, although ditch-digging fits the bill as well; tomorrow, the range would be much wider, wide enough to become meaningless.
Timo Saloniemi