Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F78406671
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
Tue, Aug 20, 16:22
Size
304 B
Mime Type
text/x-c
Expires
Thu, Aug 22, 16:22 (1 d, 22 h)
Engine
blob
Format
Raw Data
Handle
20038461
Attached To
R7571 SP4E-TB-TL-FR
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