mirror of
https://github.com/changkun/modern-cpp-tutorial.git
synced 2025-12-17 12:44:40 +03:00
book: fmt
This commit is contained in:
@@ -36,12 +36,10 @@ And return the `std::shared_ptr` pointer of this object type. For example:
|
|||||||
```cpp
|
```cpp
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
void foo(std::shared_ptr<int> i)
|
void foo(std::shared_ptr<int> i) {
|
||||||
{
|
|
||||||
(*i)++;
|
(*i)++;
|
||||||
}
|
}
|
||||||
int main()
|
int main() {
|
||||||
{
|
|
||||||
// auto pointer = new int(10); // illegal, no direct assignment
|
// auto pointer = new int(10); // illegal, no direct assignment
|
||||||
// Constructed a std::shared_ptr
|
// Constructed a std::shared_ptr
|
||||||
auto pointer = std::make_shared<int>(10);
|
auto pointer = std::make_shared<int>(10);
|
||||||
|
|||||||
@@ -38,12 +38,10 @@ order: 5
|
|||||||
```cpp
|
```cpp
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
void foo(std::shared_ptr<int> i)
|
void foo(std::shared_ptr<int> i) {
|
||||||
{
|
|
||||||
(*i)++;
|
(*i)++;
|
||||||
}
|
}
|
||||||
int main()
|
int main() {
|
||||||
{
|
|
||||||
// auto pointer = new int(10); // illegal, no direct assignment
|
// auto pointer = new int(10); // illegal, no direct assignment
|
||||||
// Constructed a std::shared_ptr
|
// Constructed a std::shared_ptr
|
||||||
auto pointer = std::make_shared<int>(10);
|
auto pointer = std::make_shared<int>(10);
|
||||||
|
|||||||
Reference in New Issue
Block a user