Back
Close

Computing with Data

elgeish
133.6K views

Smart Pointers - Part II

#include <memory>
using namespace std;
unique_ptr<int> create_unique_pointer() {
return unique_ptr<int>(new int(4));
}
int main() {
unique_ptr<int> pi1(new int(3));
// error: two unique_ptr pointers pointing to the same memory
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
Create your playground on Tech.io
This playground was created on Tech.io, our hands-on, knowledge-sharing platform for developers.
Go to tech.io
codingame x discord
Join the CodinGame community on Discord to chat about puzzle contributions, challenges, streams, blog articles - all that good stuff!
JOIN US ON DISCORD
Online Participants