본문 바로가기
언어 정리/C++_개념_lib

typedef

by 알 수 없는 사용자 2024. 1. 3.

 

alias 개념 

typedef typename std::string string;
이거나
typedef std::string string;
이거나 둘다 현재 상황에서는 동일함.

typedef std::string string; <- 이게 alias 개념으로만 쓰는 상황에 맞는 표현

 

#include <iostream>

#include <string>

using namespace std;
typedef typename std::string string;

int main()

{

    char c = 'A';
    // using std::string::operator+=

    string sss="20";
    cout << sss << endl;

    string *str_ptr = new string("Initial string");
    cout << *str_ptr << endl;

    string str_ins;
    str_ins = "AAAA";
    cout << str_ins << endl;

    return 0;

}

 

'언어 정리 > C++_개념_lib' 카테고리의 다른 글

char , 배열과 포인터 차이  (1) 2024.01.04
스마트 포인터, casting  (1) 2024.01.03
#if, 초기화리스트, const, namespace  (0) 2024.01.02
template 설명 [ fold_expression ]  (0) 2023.12.27
가변인자  (1) 2023.12.27

댓글