---
title: 1.10 Type Aliases (typedef)
description: "A type alias provides an alternate name for an existing data type. The `typedef` keyword improves readability by replacing long or complex type declarations with shorter, meaningful names. This example demonstrates how to create and use a type alias with…"
url: "https://edcret.in/docs/cpp-programming/basic-refreshers-cplusplus/1-10-type-aliases-typedef/"
updated: "2026-07-28"
category: C++ Programming / Basic Refreshers
---

# 1.10 Type Aliases (typedef)

A type alias provides an alternate name for an existing data type. The `typedef` keyword improves readability by replacing long or complex type declarations with shorter, meaningful names.

This example demonstrates how to create and use a type alias with `typedef`.

## Source Code

```
#include <iostream>

typedef unsigned int uint;

int main()
{
    uint student_count = 120;

    std::cout << "Student Count: " << student_count << '\n';

    return 0;
}
```

## Output

```
Student Count: 120
```

## Explanation

- `typedef unsigned int uint;` creates the alias `uint` for the existing type `unsigned int`.
- `typedef` does not create a new data type. It only introduces an alternate name for an existing type.
- `uint student_count = 120;` is equivalent to writing `unsigned int student_count = 120;`.
- Type aliases are commonly used to improve code readability and simplify lengthy type declarations.
- Modern C++ provides the `using` keyword as an alternative to `typedef`, especially for template aliases.
- `std::cout << "Student Count: " << student_count << '\n';` prints the value stored in the variable.
- `return 0;` terminates the program successfully.
