|
|
Tutorials

Cpp

|
Topic |
How are typedef datatypes used in C++?
How to give an alternate name for an existing datatype?
|
|
Explanation |
|
Alternate data type names are defined using the keyword "typedef" for the existing datatypes. This is used to
make the code more portable, as the data type can be changed using a single "typedef" statement.
Syntax:
typedef type newname;
Example:
#include
typedef int AGE;
void main()
{
AGE i;
cout << "Enter your age::" << endl;
cin >> i;
cout << "Your age is::" << i << endl;
}
|
Result:
Enter your age::
23
Your age is::23
In the above example typedef keyword is used to give an alternate name to "int" datatype
as "AGE".
|
| Note |
C++ is one of the most used programming languages in the world. Also known as "C with Classes".
Hope you enjoy this tutorial. Do send your feedback or suggestions on this C++ tutorial. This is a copyright content.
|
|
|
|