The city stores the culture generated by the buildings of each civilization that has owned the city at any time - this is stored as a separate variable, not in the individual buildings.
When you capture a city, any buildings and small wonders (not great wonders) that generate culture, will NOT be available to use, however the culture for each of these buildings is still stored. Interestingly, if you capture the city back, those buildings are erased (I think this is actually an unintended bug), but the total culture for your civ is retained, and will grow if the cultural improvements are rebuilt.