Create new type with typedef - C++ Data Type

C++ examples for Data Type:typedef

Introduction

A typedef requires typedef followed by the existing type and its new name.

typedef unsigned short USHORT

Demo Code

#include <iostream> 
 
int main() //from  w  w  w .j a  v a2s.c  om
{ 
    // create a type definition 
    typedef unsigned short USHORT;  
 
    // set up width and length 
    USHORT width = 6; 
    USHORT length = 4; 

    USHORT area = width * length; 
 
    std::cout << "Width: " << width << "\n"; 
    std::cout << "Length: "  << length << "\n"; 
    std::cout << "Area: " << area << "\n"; 
    return 0; 
}

Related Tutorials