- #include <iostream>
- #include <memory>
- using namespace std;
-
- int main()
- {
- int *p = new int; // 会有内存泄漏
-
- auto_ptr<int> q(new int); // 不会有内存泄漏
-
- return 0;
- }
- #include <iostream>
- #include <memory>
- using namespace std;
-
- int main()
- {
- int *p = new int; // 会有内存泄漏
-
- auto_ptr<int> q(new int); // 不会有内存泄漏
-
- return 0;
- }