| 1 | #include <memory> |
|---|---|
| 2 | #include <string> |
| 3 | |
| 4 | struct User { |
| 5 | int id = 30; |
| 6 | std::string name = "steph"; |
| 7 | }; |
| 8 | |
| 9 | int main() { |
| 10 | std::shared_ptr<int> sp_empty; |
| 11 | std::shared_ptr<int> sp_int = std::make_shared<int>(args: 10); |
| 12 | std::shared_ptr<std::string> sp_str = std::make_shared<std::string>(args: "hello"); |
| 13 | std::shared_ptr<int> &sp_int_ref = sp_int; |
| 14 | std::shared_ptr<int> &&sp_int_ref_ref = std::make_shared<int>(args: 10); |
| 15 | std::shared_ptr<User> sp_user = std::make_shared<User>(); |
| 16 | |
| 17 | return 0; // break here |
| 18 | } |
| 19 |
