0% found this document useful (0 votes)
0 views

Derived Data Type

Uploaded by

ultimatehero70
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
0 views

Derived Data Type

Uploaded by

ultimatehero70
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

Derived Data Type

Array : An array is a variable that can store multiple values of the same type.

Syntax: type array-Name [ array-Size ];

Pointer : A pointer is a variable that stores the memory address of an object.


For e.g. int * ptr;

User Defined Data 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.

enum Gfg { G1,G2, G3 };

Gfg C1 = G1;
Gfg C2 = G2;
Gfg C3 = G3;

You might also like