본문 바로가기

C++ 헤더 중복방지 C++ 프로그래밍을 하면서 성가신 작업중 하나는 헤더파일이 꼬여서 해결하는 작업이다. 별거 아닌것 같지만, 이거 때문에 시간을 왕창 잡아먹는 경우도 생기는데.. C#에서는 헤더파일 자체가 없어져 버렸기 때문에 적어도 꼬일 걱정은 안하게 되었다. 암튼, C++에서 헤더 중복방지를 위해 하는 방법은 크게 2가지 정도 있는데 하나는 #pragma once키워드와 #define을 이용하는 방법이다. The use of #pragma once can reduce build times as the compiler will not open and read the file after the first #include of the file in the translation unit. #pragma once 는 컴파일러에.. 더보기
C#에서 typedef 사용법 예전에 c++만 코딩하다 c#에는 typedef 가 없다는걸 알고 조금 당황;물론 using 키워드를 사용하면 되긴 하지만 조금 다른점이 있다. namepace EquipItem {using costumeListType = Dictionary; public class CostumeItem {protected costumeListType list; ..}} 전방선언 되어야 하므로 이렇게 namespace로 살짝 감쏴줘야 한다. 주의해야 할점은 개방형 제네릭 형식은 사용할 수 없다.List는 되지만, List는 안된다. 더보기
암시적 타입 var 키워드 C# 3.0 에서 추가된 암시적 타입 var // i is compiled as an int var i = 5; // s is compiled as a string var s = "Hello"; // a is compiled as int[] var a = new[] { 0, 1, 2 }; // expr is compiled as IEnumerable // or perhaps IQueryable var expr = from c in customers where c.City == "London" select c; // anon is compiled as an anonymous type var anon = new { Name = "Terry", Age = 34 }; // list is compiled as L.. 더보기