You do get the resource--only once you get the corresponding technology for its improvement. Say, you can settle atop a wine resource, but it won't be until you get the Monarchy technology that you'll be able to obtain the resource from there.
Even so, it's generally not advisable to settle atop resources--the tile yields they provide are generally better than their improved yields. Still, you can get a small bonus from settling atop a resource:
If the resourced tile (no forest, no improvement) yields more than the basic city tile yield (2
1
& 1
), you'll keep that bonus. For instance, you could have a riverside plantation resource (= 2
)--you'll get 2 of those instead of 1 if you settle atop it. Some players consider building a cottage atop a plantation resource to be better than the plantation itself--this is true when you do have access to the resource by other means, as the final yield of the developed cottage (town) would be greater than the plantation's yield on the long run. Be aware this won't be true during the early game.
In the case of food resources, those are almost always best harvested, unless it's a 3-food tile that can be improved by irrigation (say, rice), but that can't be irrigated due to no possibility of chain irrigating it.