Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <windows.h>
- extern int add(int,int);
- class X
- {
- public:
- X(char *name) : m_name(name) {std::cout << "Constructing " << m_name << std::endl;}
- ~X() {Sleep(1000); std::cout << "Destructing " << m_name << std::endl;}
- private:
- char *m_name;
- };
- X x1("x1");
- X x2("x2");
- X x3("x3");
- X x4("x4");
- X x5("x5");
- int main()
- {
- std::cout << "In beginning of main" << std::endl;
- int i = add(1,2);
- std::cout << i << std::endl;
- std::cout << "At end of main" << std::endl;
- }
- int add (int one, int two)
- {
- int result = one;
- result += two;
- return result;
- }
- cl /c /EHsc /Od /Zi main.cpp
- cl /c /Od /Zi /clr add.cpp
- link /debug /debugtype:cv main.obj add.obj mscoree.lib nochkclr.obj /nodefaultlib:libcmt.lib
- Constructing x1
- Constructing x2
- Constructing x3
- Constructing x4
- Constructing x5
- In beginning of main
- 3
- At end of main
- Destructing x5
- C:stacko>.main.exe
- Constructing x1
- Constructing x2
- Constructing x3
- Constructing x4
- Constructing x5
- In beginning of main
- 3
- At end of main
- Destructing x5
- Destructing x4
- Destructing x3
- C:stacko>cl /c /EHsc /Od /Zi main.cpp
- Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 16.00.30319.01 for 80x86
- Copyright (C) Microsoft Corporation. All rights reserved.
- main.cpp
- C:stacko>link main.obj
- Microsoft (R) Incremental Linker Version 10.00.30319.01
- Copyright (C) Microsoft Corporation. All rights reserved.
- C:stacko>.main.exe
- Constructing x1
- Constructing x2
- Constructing x3
- Constructing x4
- Constructing x5
- In beginning of main
- At end of main
- Destructing x5
- Destructing x4
- Destructing x3
- Destructing x2
- Destructing x1
Add Comment
Please, Sign In to add comment