You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
20 lines
396 B
C++
20 lines
396 B
C++
11 years ago
|
#include <cassert>
|
||
|
#include <iostream>
|
||
|
#include <memory>
|
||
|
|
||
|
int main() {
|
||
|
int *i = new int;
|
||
|
std::auto_ptr<int> x(i);
|
||
|
std::auto_ptr<int> y;
|
||
|
/* Note: auto_ptr is deprecated. */
|
||
|
|
||
|
y = x;
|
||
|
|
||
|
std::cout << x.get() << std::endl; // Print NULL
|
||
|
assert(x.get() == NULL);
|
||
|
std::cout << y.get() << std::endl; // Print non-NULL address i
|
||
|
assert(y.get() != NULL);
|
||
|
|
||
|
return 0;
|
||
|
}
|