Advertisement
den4ik2003

Untitled

Aug 17th, 2022
209
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.63 KB | None | 0 0
  1. #include <iostream>
  2. #include <vector>
  3.  
  4. struct S {
  5.   std::string a;
  6.  
  7.   S(S&& x) : a(std::move(x.a)) {}
  8. };
  9.  
  10. struct Base {
  11.   void f() {}
  12. };
  13.  
  14. struct Derived : Base {
  15. //  void f() override {} // CE
  16. };
  17.  
  18.  
  19. int main() {
  20.   int a = 5;
  21.   double& b = reinterpret_cast<double&>(a);
  22.   b++; // UB
  23.   std::cout << a << "\n";
  24.  
  25.   const int cx = 5;
  26.   int& x = const_cast<int&>(cx);
  27.   ++x; // UB
  28.   std::cout << cx << "\n";
  29.  
  30.   std::cout << typeid("abc").name(); // string or char?
  31.  
  32. //  S el("aaaa"); // default copy constructor
  33. //  S ell(el);
  34. //  el = ell;
  35.  
  36.   int y = 5;
  37.   int&& rr = std::move(y);
  38.   int& rrr = rr;
  39.   std::cout << y;
  40. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement