Created
February 13, 2015 01:21
-
-
Save c0ldlimit/35f3c6e2557eacc9a66f to your computer and use it in GitHub Desktop.
#lecture6
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
typedef struct X { | |
int a, b; | |
} X; | |
int main() { | |
X x = { 1, 2}; | |
X x2; | |
x2 = x; // data is copied | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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