Language/C
[따배씨] 14.20 이름 공간 공유하기
migrationArc
2021. 7. 7. 09:34
따배씨 - 따라하며 배우는 C언어
14강 구조체_2
14.20 이름 공간 공유하기 Namespace
#include <stdio.h>
int iamfunction(){
return 0;
}
int main(){
/*
namespace
- Identify parts of a program in wich a name is recognized
- You an use the same name for one variable and one tag.
- C++: use 'namespace; to use the same identifiers in the duplicated scopes
*/
int myname = 123;
{
int myname = 345;
//double myname = 3.14; //ERROR
}
struct rect {double x; double y;};
// int rect = 123; // OK in C (Not OK in C++), 권장하지 않음
struct rect rect = { 1.1, 2.2 }; // struct rect and rect are in different categories, struct 의 name & struct rect 의 name
/*
typedef struct rect rect;
rect rect = { 1.1, 2.2 }; //Not OK
*/
//int iamfunction = iamfunction(); //ERROR
return 0;
}
- 같은 이름을 다른 용도로 사용하는것은 좋지 않음
이 글의 모든 사진과 내용의 출처는 홍정모 교수님께 있음을 알려드립니다.
http://blog.naver.com/atelierjpro
실리콘 밸리의 프로그래머 : 네이버 블로그
안녕하세요! 홍정모 블로그에 오신 것을 환영합니다. 주로 프로그래밍 관련 메모 용도로 사용합니다. 강의 수강하시는 분들은 홍정모 연구소 카페로 오세요.
blog.naver.com
http://www.inflearn.com/course/following-c
홍정모의 따라하며 배우는 C언어 - 인프런 | 강의
'따배씨++'의 성원에 힘입어 새롭게 개발된 C 언어로 시작하는 프로그래밍 입문 강의입니다. '따배씨'와 함께 프로그래밍 인생을 업그레이드 해보세요., 따라하며 배우는 C언어 '따배씨++'의 성원
www.inflearn.com