What is enum with example?

An enum type is a special data type that enables for a variable to be a set of predefined constants . The variable must be equal to one of the values that have been predefined for it. Common examples include compass directions (values of NORTH, SOUTH, EAST, and WEST) and the days of the week.

Read more

What is enum in OOP?

“The enum keyword is used to declare an enumeration , a distinct type that consists of a set of named constants called the enumerator list. … However, an enum can also be nested within a class or struct. By default, the first enumerator has the value 0 and the value of each successive enumerator is increased by 1.

Read more

What is union and structure in C++?

A union is like a struct in that it generally has several fields, all of which are public by default. Unlike a struct, however, only one of the fields is used at any given time. In other words, it is a structure that allows the same storage space to be used to store values of different data types at different times.

Read more

What is typedef in C example?

typedef is a reserved keyword in the programming languages C and C++. It is used to create an additional name (alias) for another data type, but does not create a new type, except in the obscure case of a qualified typedef of an array type where the typedef qualifiers are transferred to the array element type.

Read more