Guest User

Untitled

a guest
Jul 16th, 2018
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.58 KB | None | 0 0
  1. #include <iostream>
  2. #include <windows.h>
  3.  
  4. extern int add(int,int);
  5.  
  6. class X
  7. {
  8. public:
  9. X(char *name) : m_name(name) {std::cout << "Constructing " << m_name << std::endl;}
  10. ~X() {Sleep(1000); std::cout << "Destructing " << m_name << std::endl;}
  11. private:
  12. char *m_name;
  13. };
  14.  
  15. X x1("x1");
  16. X x2("x2");
  17. X x3("x3");
  18. X x4("x4");
  19. X x5("x5");
  20.  
  21. int main()
  22. {
  23. std::cout << "In beginning of main" << std::endl;
  24. int i = add(1,2);
  25. std::cout << i << std::endl;
  26. std::cout << "At end of main" << std::endl;
  27. }
  28.  
  29. int add (int one, int two)
  30. {
  31. int result = one;
  32. result += two;
  33. return result;
  34. }
  35.  
  36. cl /c /EHsc /Od /Zi main.cpp
  37. cl /c /Od /Zi /clr add.cpp
  38. link /debug /debugtype:cv main.obj add.obj mscoree.lib nochkclr.obj /nodefaultlib:libcmt.lib
  39.  
  40. Constructing x1
  41. Constructing x2
  42. Constructing x3
  43. Constructing x4
  44. Constructing x5
  45. In beginning of main
  46. 3
  47. At end of main
  48. Destructing x5
  49.  
  50. C:stacko>.main.exe
  51. Constructing x1
  52. Constructing x2
  53. Constructing x3
  54. Constructing x4
  55. Constructing x5
  56. In beginning of main
  57. 3
  58. At end of main
  59. Destructing x5
  60. Destructing x4
  61. Destructing x3
  62.  
  63. C:stacko>cl /c /EHsc /Od /Zi main.cpp
  64. Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 16.00.30319.01 for 80x86
  65. Copyright (C) Microsoft Corporation. All rights reserved.
  66.  
  67. main.cpp
  68.  
  69.  
  70. C:stacko>link main.obj
  71. Microsoft (R) Incremental Linker Version 10.00.30319.01
  72. Copyright (C) Microsoft Corporation. All rights reserved.
  73.  
  74. C:stacko>.main.exe
  75. Constructing x1
  76. Constructing x2
  77. Constructing x3
  78. Constructing x4
  79. Constructing x5
  80. In beginning of main
  81. At end of main
  82. Destructing x5
  83. Destructing x4
  84. Destructing x3
  85. Destructing x2
  86. Destructing x1
Add Comment
Please, Sign In to add comment