typedef
?The typedef
keyword allows you to create an alias (alternative name) for existing data types. This can make your code more readable and easier to maintain.
Think of it like giving a nickname to a type. Instead of writing the full type name every time, you can use your custom alias.
// Instead of writing this everywhere:
unsigned long long int userId;
// You can create an alias:
typedef unsigned long long int UserId;
UserId userId; // Much cleaner!
This is especially useful for complex types or when you want to make your code's intent clearer.
Create a typedef
alias for double
called Price
, then declare a variable named itemPrice
using your new alias.
Click "Check Answer" to run your code.