First, let me clarify: the switch does not learn addresses by flooding. The switch learns addresses by examining the source address of each frame received, then updating the MAC address if necessary.
The mac address table lists each mac address received and the associated port (among other things). So your switch would have an entry for mac D listing port 3, and an entry for mac C, also listing port 3.
Now if the switch gets a frame destined for either C or D, it knows to forward it out port 3.
Switches don't use ARP to learn MAC addresses. Switches lean which MAC address is on which port simply by inspecting the source addresses on frames which come into the switch ports.
Switches don't understand layer-3 (except for layer-3 switches). To the switch, a router is just another host on the LAN.
All the above is from the perspective of layer-2 switch operation. A switch may have a management address, but, again, this is just another host on the LAN, and the management will use ARP and have a configured gateway and learn its MAC address with ARP, but it really has nothing to do with how the switching operates.
A host wishing to send an IP packet to another host will look in its ARP cache for the MAC address. If there isn't an entry in its ARP cache, it will send an ARP request to resolve the layer-3 IP address to the layer-2 MAC address. It will then build a layer-2 frame with this information and send it to the switch. If the destination IP address is on a different network, the host will look for the MAC address of its configured gateway in its ARP cache, and send an ARP request if it isn't in there, build a frame and send it out, just as it would for any other host.
As the frames come into the switch, the switch will look at the source MAC addresses, and use that to build its MAC address table, not the same as an ARP cache. When a switch receives a frame with a destination MAC address which isn't in its MAC address table, it will flood the frame out every port; it does not use ARP requests to discover this. It doesn't take a switch very long to build its MAC table since it take only one frame from each host to populate the MAC address table.
Best Answer
The entry in the switch mac table has a timestamp and all records have a lifetime. (300 seconds is a common value but it can be another value, and it may be configurable, depending on the switch vendor / model / software version).
So when you disconnect a device, the entry will be removed after some times.
Additionally some switches will immediately remove all entries listing a port if this port goes down.
A switch will keep a single entry for a given mac address, and if needed update it. So if you move a device from one port to another, when the device will sent a frame, the switch will update the mac table with the new port.
Things become more complex when you have many switches interconnected.