Lec # 6 Structures in C++ Part 1
Lec # 6 Structures in C++ Part 1
Structure
Member of Structure
Variables
Problem with Array
Although arrays greatly improved our ability to store
data, there is one major drawback to their use…. Each
element (each box) in an array must be of the same
data type.
Declare Structure
1. Declare Structure
• Struct keyword is used for creating a structure.
1. Declare Structure
• Struct keyword is used for creating a structure.
• Syntax:
struct type_name
{
member_type1 member_name1;
member_type1 member_name1;
member_type1 member_name1;
.
.
.
}
Approach 1 (Declaration of a structure)
Example
S1 = S2;