-Knowledge
-Object 객체: 값, 문자열 등이 메모리에 저장된 것. 메모리의 위치가 포함됨. 객체 지향 프로그래밍에서 클래스의 인스턴스이다.
-Variables 변수: 자료를 저장할 수 있는 메모리 공간, 주소의 다른 이름이다. Ex) int x = 10; 의 x
-lvalue, rvalue:
Ex) x = 10;
(lvalue) = (rvalue)
#include <iostream>
int main()
{
int x = 123; // initialization
// x = 5; assignment
std::cout << x << std::endl;
return 0;
}
x라는 변수를 123이라는 값으로 초기화하고 출력함.
-Practice
#include <iostream>
int main()
{
int x = 1;
x = x + 2;
std::cout << x << std::endl;
int y = x;
std::cout << y << std::endl;
std::cout << x + y << std::endl;
std::cout << x << std::endl;
/*int z;
std::cout << z << std::endl;*/
//z는 초기화되지 않은 값이므로 오류 발생
return 0;
}
-Personal
기초 개념들을 확실하게 정리하고 넘어가자. 이제 시작이다.
'Computer Science > C++' 카테고리의 다른 글
C++ -5- 홀수 짝수 판별 프로그램 (0) | 2021.04.07 |
---|---|
C++ -4- While 반복문과 함수를 이용한 간단한 덧셈 계산기 (0) | 2021.04.05 |
C++ -3- 함수와의 첫 만남 (0) | 2021.04.05 |
C++ -2- 입출력 스트림과의 첫 만남 (0) | 2021.04.05 |
C++ -0- Visual Studio 2019를 사용해 Hello World 출력 (0) | 2021.04.03 |
댓글