Take copper sulphate solution in a glass trough. Dip a carbon rod in the solution. Use it as the cathode, i.e. connect it to the negative terminal of the battery. Take a pure copper strip, dip it in the solution and use it as anode, i.e. connect it to the positive terminal. Pass electricity through the solution by closing the circuit. The positively charged copper ions from the solution will move towads the carbon rod which is acting as the cathode. The copper ions that are positively charged get attracted towards the negative electrode, the carbon rod get deposited on it. But how does the loss of copper from the solution get compensated? The copper anode releases copper ions into the solution, thus compensating for the loss. Since copper sulphate is an ionic compound, it constitutes ions

When electricity is passed through the solution, the cations (i.e. positively charged copper ions) move towards the cathode. Here they gain electrons and get deposited as copper metal.
At cathode:
Cu2+ + 2e– → Cu
The sulphate ions remain in the solution. Copper at anode loses electrons and goes into the solution as copper ions to replenish the copper ions deposited at cathode.
An anode:
Cu→ Cu2++ 2e–