Skip to content

Instantly share code, notes, and snippets.

@strager
Created December 25, 2019 06:55
Show Gist options
  • Save strager/704ffa3ba68e283e724a098a6e30831a to your computer and use it in GitHub Desktop.
Save strager/704ffa3ba68e283e724a098a6e30831a to your computer and use it in GitHub Desktop.
#include <iostream>
#include <string>
#include <vector>
using namespace std;
void print_vector(vector<string> items) {
for (string s : items) {
cout << ' ' << s;
}
}
int main() {
vector<string> x = {"hello"};
vector<string> y = x;
x.push_back("world");
cout << "x:";
print_vector(x);
cout << '\n';
cout << "y:";
print_vector(y);
cout << '\n';
struct person {
string name;
};
person me = person{"James"};
person buddy = me;
me.name = "strager";
cout << "me.name: " << me.name << '\n';
cout << "buddy.name: " << buddy.name << '\n';
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment