Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F78977276
shared_pointers.cpp
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Sat, Aug 24, 02:22
Size
309 B
Mime Type
text/x-c
Expires
Mon, Aug 26, 02:22 (2 d)
Engine
blob
Format
Raw Data
Handle
20130619
Attached To
R9360 PCSC_git
shared_pointers.cpp
View Options
#include <iostream>
#include <memory>
std
::
shared_ptr
<
double
>
get_vector
(
int
n
)
{
return
std
::
shared_ptr
<
double
>
(
new
double
[
n
]);
}
int
main
()
{
std
::
shared_ptr
<
double
>
ptr1
=
get_vector
(
10
);
std
::
shared_ptr
<
double
>
ptr2
=
ptr1
;
// memory of pointer freed when
// ptr1 and ptr2 are out of scope
}
Event Timeline
Log In to Comment