Skip to content

Instantly share code, notes, and snippets.

@c0ldlimit
Created February 13, 2015 01:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save c0ldlimit/35f3c6e2557eacc9a66f to your computer and use it in GitHub Desktop.
Save c0ldlimit/35f3c6e2557eacc9a66f to your computer and use it in GitHub Desktop.
#lecture6
#include <stdio.h>
typedef struct X {
int a, b;
} X;
int main() {
X x = { 1, 2};
X x2;
x2 = x; // data is copied
}
#include <iostream>
using std::cout;
using std::endl;
typedef struct X {
int a, b;
void f() {}
} X;
void f(X arg) { // creates space on the stack for 'arg' and copies the value passed into it
cout << &arg << endl;
}
int main() {
X x = {1, 2};
X x2;
x2 = x; // data is copied
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment