lundi 18 mai 2020

C++: Move Semantic with Integer

int c = 2;
int d = std::move(c);
std::cout << "c is: " << c << std::endl;
std::cout << "d is: " << d << std::endl;

this code output:

c is: 2

d is: 2

I thought that after move(c) to d, c will be empty, why does it still have 2 as its value ? Can you anyone please help me explain this ? Thank you.

Aucun commentaire:

Enregistrer un commentaire