fork download
  1. #include <iostream>
  2. #include <vector>
  3.  
  4. class Car{
  5. public:
  6. int weight;
  7.  
  8. Car(int weight): weight(weight){
  9.  
  10. };
  11.  
  12. Car(Car&& other){
  13. std::cout<<"moved!"<<std::endl;
  14. this->weight=other.weight;
  15. }
  16.  
  17. Car(const Car& other){
  18. std::cout<<"copied!"<<std::endl;
  19. this->weight=other.weight;
  20. }
  21. };
  22.  
  23. int main() {
  24. std::vector<Car> vec;
  25. vec.push_back(Car(1));
  26. return 0;
  27. }
Success #stdin #stdout 0.01s 5288KB
stdin
Standard input is empty
stdout
moved!