Skip to content

Instantly share code, notes, and snippets.

@Mooophy
Created November 28, 2014 11:17
Show Gist options
  • Select an option

  • Save Mooophy/d9343e207918f9fe7c9a to your computer and use it in GitHub Desktop.

Select an option

Save Mooophy/d9343e207918f9fe7c9a to your computer and use it in GitHub Desktop.
#include <iostream>
#include <vector>
#include <memory>
int main()
{
//! (*v).push_back(),这样对vector似乎并不适用。
//!
//! -- check the code blew
auto p = std::make_shared<std::vector<int>>();
(*p).push_back(42);
p->push_back(999);
std::cout << (*p)[0] << " " << (*p)[1] << std::endl;
return 0;
}
//! output:
//!
//42 999
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment