Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //
- // main.cpp
- // copywithsmartpointer
- //
- // Created by Rizky Herucakra on 7/2/13.
- // Copyright (c) 2013 Rizky Herucakra. All rights reserved.
- //
- #include <iostream>
- #include <memory>
- using namespace std;
- class Sample
- {
- public:
- shared_ptr<int> ptr;
- Sample(int i)
- {
- ptr = shared_ptr<int>( new int(i));
- }
- void PrintVal()
- {
- cout << "The value is " << *ptr;
- }
- };
- void SomeFunc(Sample x)
- {
- cout << "Say i am in someFunc " << endl;
- }
- int main()
- {
- Sample s1 = 10;
- SomeFunc(s1);
- s1.PrintVal();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement