Derived Data Type
Derived Data Type
Array : An array is a variable that can store multiple values of the same type.
1. Class: Class is a fundamental block of a program that has its own set of methods and variables.
Syntax:
class MyClass { // The class
public: // Access specifier
int myNum; // Attribute (int variable)
string myString; // Attribute (string variable)
};
2. Structures: Structure is a collection of variables of different data types under a single name. It is
similar to a class in that, both holds a collection of data of different data types.
Syntax:
struct { // Structure declaration
int myNum; // Member (int variable)
string myString; // Member (string variable)
} myStructure; // Structure variable
3. Union: A union is a type of structure that can be used where the amount of memory used is a key
factor.
union GFG {
int G1;
char G2;
float G3;
};
4. Enumeration: Enums are user-defined types that consist of named integral constants.
Gfg C1 = G1;
Gfg C2 = G2;
Gfg C3 = G3;