코가손의 블로그

[C++/기초] using vs typedef 본문

C++/문법

[C++/기초] using vs typedef

Cogason 2021. 11. 11. 20:17

1. typedef 보다 직관성이 좋다.

typedef __int64 id;
using id2 = __int64;

typedef void(*MyFunc)();
using MyFunc2 = void(*)();

int main()
{
    MyFunc f1 = &함수;
    MyFunc2 f2 = &함수;
    
    f1();
    f2();
}

 

2. 템플릿에 활용된다.

template<typename T>
using List = std::list<T>;

'C++ > 문법' 카테고리의 다른 글

[C++/기초] ModernC++  (0) 2021.12.19
C++ 중괄호 초기화 {}  (0) 2021.11.11
C++ 콜백 함수  (0) 2021.11.11
C++ 캐스팅(static_cast, dynamic_cast, const_cast, reinterpret_cast)  (0) 2021.11.11
C++ 문자와 문자열  (0) 2021.11.11
Comments