-
C++연습_전역변수(Global variable)코딩Coding/C++_연습 2020. 9. 20. 02:04728x90
#include <iostream> const int g_y{ 1 }; constexpr int g_z{ 2 }; void doSomething() { std::cout << g_y << '\n'; std::cout << g_z << '\n'; } int main() { doSomething(); std::cout << g_y << '\n'; std::cout << g_z << '\n'; return 0; }
결과
www.learncpp.com/cpp-tutorial/introduction-to-global-variables/
6.4 — Introduction to global variables | Learn C++
6.4 — Introduction to global variables By Alex on June 19th, 2007 | last modified by nascardriver on February 15th, 2020 In lesson 6.3 -- Local variables, we covered that local variables are variables defined inside a function (or function parameters). L
www.learncpp.com
반응형'코딩Coding > C++_연습' 카테고리의 다른 글
C++연습_반복되는 문자 숫자 세기_입력하는거로 수정해야함 (0) 2020.11.28 C++연습_문자열 연결 (0) 2020.11.26 C++연습_Hello, World 출력하기 (0) 2020.10.17 C++연습_프로그램 실행 폴더 알아내기 (0) 2020.09.22 C++연습_문자열 비교하기(string.compare) (0) 2020.09.18 C++연습_날짜와 시간을 문자열로 변환하기(localtime) (0) 2020.09.18 C++연습_난수 생성하기(Random number) (0) 2020.09.17 C++연습_Hello World출력 (0) 2020.09.02