y0u_bat
C++ Language Study 1st 본문
C++ Language Study 1st
1. Print
#include <iostream>
using namespace std;
int main()
{
cout << "Hello World!" << endl;
return 0;
}
2. Input
#include <iostream>
using namespace std;
int main()
{
int input=0;
cin >> input;
cout << input << endl;
}
3-1. Reference
#include <iostream>
using namespace std;
int test(int &p)
{
p = 3;
return 0;
}
int main()
{
int number = 5;
cout << number << endl;
test(number);
cout << number << endl;
}
Result
5
3
3-2. Reference
#include <iostream>
using namespace std;
int main()
{
int x;
int &y = x;
int &z = y;
x=1;
cout << x << y << z << endl;
y=2;
cout << x << y << z << endl;
z=3;
cout << x << y << z << endl;
}
Result
111
222
333
3-3. Reference
#include <iostream>
using namespace std;
int main()
{
int x[2][2] = {1,2,3,4};
int (&ref)[2][2] = x;
for(int i=0;i<2;i++)
for(int j=0;j<2;j++)
cout << x[i][j] << endl;
}
Result
1
2
3
4
Arrange Reference is usually don't use
* Arrange Reference size == Arrange size
'프로그래밍 > C++' 카테고리의 다른 글
[열혈C++] 단계별 OOP 프로젝트 1단계 (0) | 2016.02.26 |
---|
Comments