Total members 11890 |It is currently Thu Apr 18, 2024 6:30 pm Login / Join Codemiles

Java

C/C++

PHP

C#

HTML

CSS

ASP

Javascript

JQuery

AJAX

XSD

Python

Matlab

R Scripts

Weka





Usage of typedef keyword in C++
cpp code
/* C typedef assigns a name to a type.  Its syntax can be really awful. */
#include <stdio.h>

/* Make fred an alias for the type name integer. */
typedef int fred;

/* Assign a type name to an enumeration. */
typedef enum { Sun, Mon, Tue, Wed, Thu, Fri, Sat} day;

int main()
{
fred m = 5;
day today = Fri;

if(today == m) printf("Yes!\n");
else printf("Nope.\n");
}


The typedef is the only way to create type names in plain C. It essentially aliases for types for other types. It still exists in C++, but is not used very often, since classes are usually used to create new types.



_________________
Please recommend my post if you found it helpful


Author:
Beginner
User avatar Posts: 95
Have thanks: 2 time
Post new topic Reply to topic  [ 1 post ] 

  Related Posts  to : Typedef Declaration
 JSP Declaration Tag     -  
 Enum Declaration     -  



Topic Tags

C++ Variables
cron





Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
All copyrights reserved to codemiles.com 2007-2011
mileX v1.0 designed by codemiles team
Codemiles.com is a participant in the Amazon Services LLC Associates Program, an affiliate advertising program designed to provide a means for sites to earn advertising fees by advertising and linking to Amazon.com