Created
October 26, 2012 14:51
-
-
Save Jack2/3959239 to your computer and use it in GitHub Desktop.
C++가 보이는 그림책 - page.103 예제 vs page.104 예제
This file contains hidden or 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 namespace std; | |
struct Person { | |
char name[50] ; | |
int age ; | |
} ; | |
// 책에서 참조에 의한 전달이라고 표기되어 있음 | |
void PrintPersonRef(const Person &psn) | |
{ | |
cout << psn.name << "씨" << psn.age << "세" << endl; | |
} | |
//책에서 주소(어드레스)에 의한 전달이라고 표기되어 있음 | |
void PrintPersonPtr(const Person *psn) | |
{ | |
cout << psn->name << "씨" << psn->age << "세" << endl; | |
} | |
int main() | |
{ | |
Person shain1 = [ "Shiori", 18} ; | |
PrintPersonRef(shain1); | |
PrintPersonPtr(&shain1); | |
return 0; | |
} | |
This file contains hidden or 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
. | |
. | |
. | |
struct Person { | |
char name[50]; | |
int age; | |
} ; | |
//책에서 참조에 의한 전달이라고 표기되어 있음 | |
void PrintPersonRef(Person *psn); | |
//책에서 주소(어드레스)에 의한 전달이라고 표기되어 있음 | |
void PrintPersonPtr(Person &psn); | |
//책에서 값에 의한 전달이라고 표기되어 있음 | |
void PrintPersonVal(Person psn); | |
int main() | |
{ | |
PrintPersonRef(shain1); | |
PrintPersonPtr(&shain1); | |
PrintPersonVal(shain1); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment