Advertisement
Guest User

Untitled

a guest
Oct 31st, 2014
186
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.90 KB | None | 0 0
  1. // testrvalue.cpp: определяет точку входа для консольного приложения.
  2. //
  3.  
  4. #include "stdafx.h"
  5. #include <iostream>
  6.  
  7. class b
  8. {
  9. public:
  10.     b()
  11.     {
  12.         std::cout << "b::b" << std::endl;
  13.     }
  14.  
  15.     ~b()
  16.     {
  17.         std::cout << "b::~b" << std::endl;
  18.     }
  19.  
  20.     b(b&&)
  21.     {
  22.         std::cout << "b && o" << std::endl;
  23.     }
  24.  
  25.     b(const b&)
  26.     {
  27.         std::cout << "const b&" << std::endl;
  28.     }
  29.  
  30.     void done()
  31.     {
  32.         std::cout << "done" << std::endl;
  33.     }
  34. };
  35.  
  36. class a
  37. {
  38.     b b_;
  39.  
  40. public:
  41.  
  42.     a()
  43.     {
  44.         std::cout << "a::a" << std::endl;
  45.     }
  46.  
  47.     ~a()
  48.     {
  49.         std::cout << "a::~a" << std::endl;
  50.     }
  51.  
  52.     a(a&&)
  53.     {
  54.         std::cout << "a&&" << std::endl;
  55.     }
  56.  
  57.     a(const a&)
  58.     {
  59.         std::cout << "const a&" << std::endl;
  60.     }
  61.  
  62.     void done()
  63.     {
  64.         b_.done();
  65.     }
  66. };
  67.  
  68.  
  69. a construct()
  70. {
  71.     return a();
  72. }
  73.  
  74. int _tmain(int argc, _TCHAR* argv[])
  75. {
  76.     auto t = construct();
  77.  
  78.     t.done();
  79.  
  80.     return 0;
  81. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement