Skip to content

Instantly share code, notes, and snippets.

@xunkai55
Created November 3, 2015 05:36
Show Gist options
  • Save xunkai55/7c6cd5b6be0fcff9c7fe to your computer and use it in GitHub Desktop.
Save xunkai55/7c6cd5b6be0fcff9c7fe to your computer and use it in GitHub Desktop.
#include <iostream>
#include <vector>
using namespace std;
struct S {
vector<int> a;
S() { a.clear(); }
S(const S& toher) = default;
};
int main() {
S b;
b.a.clear();
b.a.push_back(3);
S c = b;
cout << c.a.size() << endl;
cout << b.a[0] << " " << c.a[0] << endl;
b.a[0] = 2;
cout << b.a[0] << " " << c.a[0] << endl;
c.a[0] = 5;
cout << b.a[0] << " " << c.a[0] << endl;
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment