fork(3) download
  1. #include <iostream>
  2. #include <vector>
  3. #include <memory>
  4. using namespace std;
  5.  
  6. int main() {
  7.  
  8. cout<<"999999"<<endl;
  9.  
  10. shared_ptr<int> sp1(new int(100));
  11. cout<<"sp1的值: "<<*sp1<<endl;
  12.  
  13. shared_ptr<vector<int>> temp1(new vector<int>());
  14. cout<<"temp1的长度: "<<temp1->size()<<endl;
  15.  
  16. temp1->push_back(111);
  17. cout<<"temp1的长度: "<<temp1->size()<<endl;
  18.  
  19. // std::shared_ptr<vector<int>> temp2;
  20. // cout<<"temp2的长度: "<<temp2->size()<<endl;
  21.  
  22. return 0;
  23. }
Success #stdin #stdout 0s 5316KB
stdin
Standard input is empty
stdout
999999
sp1的值: 100
temp1的长度: 0
temp1的长度: 1