SlideShare a Scribd company logo
1 of 31
0
 Outline:
◦ Definition of Structures
◦ Array of structures
◦ Structure and functions
◦ Enumerated data type
 A structure in C++ are a group of data elements grouped together under
one name. these data elements known as a member of a structure.
 A structure type in C++ is called struct.
 A struct is heterogeneous in that it can be composed of data of different
types.
 In contrast, array is homogeneous since it can contain only data of the same
type.
1
 Unlike an array, a structure can contain many different data types (int,
string, bool, etc.).
 Structures hold data that belong together.
 Examples:
◦ Student record: student id, name, major, gender, start year, …
◦ Bank account: account number, name, currency, balance, …
◦ Address book: name, address, telephone number, …
 In database applications, structures are called records.
 Individual components of a struct type are called members (or fields).
2
 Members can be of different types (simple, array or
struct).
 A struct is named as a whole while individual members
are named using field identifiers.
 Complex data structures can be formed by defining
arrays of structs.
3
 The keyword ‘struct ‘ is used for creating a structure.
 The structure declaration appears at the top of the source code file
before any variables and structures are defined.
 Then inside the curly braces, you can declare one or more members
(declare variables inside curly braces) of that structure. For
example:
 Definition of a structure:
struct structure_name
{
data-type member-1;
data-type member-2;
data-type member-3;
data-type member-4;
} ;
4
 Example:
struct Date {
int day;
int month;
int year;
} ;
The “Date” structure
has 3 members,
day, month & year.
Notice the
required ;
5
 Example:
struct StudentInfo{
int Id;
int age;
char Gender;
double CGPA;
};
 Example:
struct StudentGrade{
char Name[15];
char Course[9];
int Lab[5];
int Homework[3];
int Exam[2];
};
The “StudentInfo”
structure has 4 members
of different types.
The “StudentGrade”
structure has 5
members of
different array types.
 struct names commonly begin with an uppercase
letter
 Multiple fields of same type can be in a comma-
separated list.
string name,address;
6
The “Person”
structure has 3 members
of different types.
7
 Struct declaration does not allocate memory or create
variables.
 To allocate memory spaces for structure members, we must
create an object which is called structure variable.
Let’s create a structure having 3 variable a, b, c.
Method 1:
struct structure_name
{
member definition;
member definition;
...
member definition;
} ;
struct structure_name a,b,c;
8
Method 2:
struct structure_name
{
member definition;
member definition;
...
member definition;
} ;
structure_name a,b,c;
Method 3
struct structure_name
{
member definition;
member definition;
...
member definition;
}a,b,c ;
 To access any member of a structure, we use the member access operator
(.). The member access operator is coded as a period between the structure
variable name and the structure member that we wish to access.
◦ structure variable name. structure member
9
p.name; is char array element of
structure p.
p.age; is the integer element of
structure p.
p.salary; is a float element of
structure p.
The “Person”
structure has 3 members
of different types.
name
age
salary
Person
name
age
salary
p
 To display the contents of a struct variable, you must display each field
separately, using the dot operator
struct Student
{
int studentID;
string name;
short year;
double gpa;
};
Student s1;
cout << s1; // won’t work!
cout << s1.studentID << endl;
cout << s1.name << endl;
cout << s1.year << endl;
cout << s1.gpa;
10
Wrong:
Correct
11
 Cannot initialize members in the structure declaration,
because no memory has been allocated yet.
struct Student // Illegal
{ //initialization
int studentID = 1145;
string name = "Alex";
short year = 1;
float gpa = 2.95;
};
12
 Structure members are initialized at the time a structure
variable is created.
 Can initialize a structure variable’s members with
either
◦ an initialization list
◦ a constructor
 An initialization list is an ordered set of values,
separated by commas and contained in { }, that
provides initial values for a set of data members.
{12, 6, 3} // initialization list
// with 3 values
13
 Order of list elements matters: The first value
initializes the first data member, the second value
initializes the second data member, etc.
 Elements of an initialization list can be constants,
variables, or expressions.
{12, W, L/W + 1} // initialization
//List with 3 items
14
Initialization list example:
struct Dimensions
{
int length,
int width,
int height;
};
Dimensions box = {12,6,3};
box
length 12
width 6
height 3
 Can initialize just some members, but cannot skip over
members.
Dimensions box1 = {12,6}; //OK
Dimensions box2 = {12,,3}; //illegal
 Can’t omit a value for a member without omitting values for all following members.
15
C++ Program to assign data to members of a structure variable and
display it.
Output
Enter Full name: abebe
kebede
Enter age: 27
Enter salary: 1024.4
Displaying Information.
Name: abebe kebede
Age: 27
Salary: 1024.4
 We can create an array of structures. thus we can use
the same structure for more than one variable which
adds more flexibility to your program.
 In another word array of structure means making the
structure variable an array.
 suppose we need to store the data of 100 students.
Declaring 100 separate variables of the structure is
definitely not a good option. For that, we need to create
an array of structures.
16
17
Example:
 We can also create an object of a structure in another
structure as members of a structure.
 If you have data like student information (name, id, age,
section), and the address of a person (kebele, kefle-Ketama,
and road name). what are you going to do? You must be
able to incorporate this type of data in other structs. The
following program declares two structs one for address and
the other for students.
18
19
 Structure variables can be passed to a function and returned in a similar way as
normal arguments.
 There are two methods by which we can pass structures to functions.
• Passing by Value
• Passing by Reference
 The call/pass-by value method of passing arguments to a function, copies the actual
value of an argument into the formal parameter of the function.
 In this case changes made to the parameter inside the function have no effect on the
argument.
 By default, C++ uses call-by-value to pass arguments. In general, this means that
code within a function cannot alter the arguments used to call the function.
20
 The call/pass by reference method of passing arguments to
a function, copies the reference of an argument into the
formal parameter.
 Inside the function, the reference is used to access the actual
argument used in the call. this means that changes made to
the parameter affect the passed arguments.
 To pass the value by reference, argument reference is
passed to the functions just like any other value.
21
22
23
24
25
 An enumeration is a user-defined data type that consists
of integral constants.
 Enums or enumerations are generally used when you
expect the variable to select one value from the
possible set of values.
 To define an enumeration, the keyword enum is used.
26
27
By default, spring is 0, summer is 1 and so on. You can change the default value of an
enum element during declaration (if necessary).
28
Method 1 Method 2
29
30
Thank you!!!

More Related Content

Similar to Chapter4.pptx

Structure prespentation
Structure prespentation Structure prespentation
Structure prespentation ashu awais
 
data structure and c programing concepts
data structure and c programing conceptsdata structure and c programing concepts
data structure and c programing conceptskavitham66441
 
Pointers and Structures
Pointers and StructuresPointers and Structures
Pointers and StructuresGem WeBlog
 
Structures in c language
Structures in c languageStructures in c language
Structures in c languagetanmaymodi4
 
Structures in c language
Structures in c languageStructures in c language
Structures in c languageTanmay Modi
 
Structure in c language
Structure in c languageStructure in c language
Structure in c languagesangrampatil81
 
VIT351 Software Development VI Unit4
VIT351 Software Development VI Unit4VIT351 Software Development VI Unit4
VIT351 Software Development VI Unit4YOGESH SINGH
 
structures and unions in 'C'
structures and unions in 'C'structures and unions in 'C'
structures and unions in 'C'illpa
 

Similar to Chapter4.pptx (20)

lec14.pdf
lec14.pdflec14.pdf
lec14.pdf
 
Structure & union
Structure & unionStructure & union
Structure & union
 
Unit 1_ADC.pptx
Unit 1_ADC.pptxUnit 1_ADC.pptx
Unit 1_ADC.pptx
 
1. structure
1. structure1. structure
1. structure
 
Structure in C
Structure in CStructure in C
Structure in C
 
Structure prespentation
Structure prespentation Structure prespentation
Structure prespentation
 
data structure and c programing concepts
data structure and c programing conceptsdata structure and c programing concepts
data structure and c programing concepts
 
Pointers and Structures
Pointers and StructuresPointers and Structures
Pointers and Structures
 
Chapter 8 Structure Part 2 (1).pptx
Chapter 8 Structure Part 2 (1).pptxChapter 8 Structure Part 2 (1).pptx
Chapter 8 Structure Part 2 (1).pptx
 
Structures in c language
Structures in c languageStructures in c language
Structures in c language
 
Structures in c language
Structures in c languageStructures in c language
Structures in c language
 
structures_v1.ppt
structures_v1.pptstructures_v1.ppt
structures_v1.ppt
 
structures_v1.ppt
structures_v1.pptstructures_v1.ppt
structures_v1.ppt
 
C Structures & Unions
C Structures & UnionsC Structures & Unions
C Structures & Unions
 
Structure and Enum in c#
Structure and Enum in c#Structure and Enum in c#
Structure and Enum in c#
 
Structure in c language
Structure in c languageStructure in c language
Structure in c language
 
VIT351 Software Development VI Unit4
VIT351 Software Development VI Unit4VIT351 Software Development VI Unit4
VIT351 Software Development VI Unit4
 
structures and unions in 'C'
structures and unions in 'C'structures and unions in 'C'
structures and unions in 'C'
 
Unit 5 (1)
Unit 5 (1)Unit 5 (1)
Unit 5 (1)
 
DS_PPT.ppt
DS_PPT.pptDS_PPT.ppt
DS_PPT.ppt
 

Recently uploaded

VICTOR MAESTRE RAMIREZ - Planetary Defender on NASA's Double Asteroid Redirec...
VICTOR MAESTRE RAMIREZ - Planetary Defender on NASA's Double Asteroid Redirec...VICTOR MAESTRE RAMIREZ - Planetary Defender on NASA's Double Asteroid Redirec...
VICTOR MAESTRE RAMIREZ - Planetary Defender on NASA's Double Asteroid Redirec...VICTOR MAESTRE RAMIREZ
 
Biology for Computer Engineers Course Handout.pptx
Biology for Computer Engineers Course Handout.pptxBiology for Computer Engineers Course Handout.pptx
Biology for Computer Engineers Course Handout.pptxDeepakSakkari2
 
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptxDecoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptxJoão Esperancinha
 
Current Transformer Drawing and GTP for MSETCL
Current Transformer Drawing and GTP for MSETCLCurrent Transformer Drawing and GTP for MSETCL
Current Transformer Drawing and GTP for MSETCLDeelipZope
 
IVE Industry Focused Event - Defence Sector 2024
IVE Industry Focused Event - Defence Sector 2024IVE Industry Focused Event - Defence Sector 2024
IVE Industry Focused Event - Defence Sector 2024Mark Billinghurst
 
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdf
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdfCCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdf
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdfAsst.prof M.Gokilavani
 
Artificial-Intelligence-in-Electronics (K).pptx
Artificial-Intelligence-in-Electronics (K).pptxArtificial-Intelligence-in-Electronics (K).pptx
Artificial-Intelligence-in-Electronics (K).pptxbritheesh05
 
INFLUENCE OF NANOSILICA ON THE PROPERTIES OF CONCRETE
INFLUENCE OF NANOSILICA ON THE PROPERTIES OF CONCRETEINFLUENCE OF NANOSILICA ON THE PROPERTIES OF CONCRETE
INFLUENCE OF NANOSILICA ON THE PROPERTIES OF CONCRETEroselinkalist12
 
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICSAPPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICSKurinjimalarL3
 
Call Girls Narol 7397865700 Independent Call Girls
Call Girls Narol 7397865700 Independent Call GirlsCall Girls Narol 7397865700 Independent Call Girls
Call Girls Narol 7397865700 Independent Call Girlsssuser7cb4ff
 
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...Soham Mondal
 
Electronically Controlled suspensions system .pdf
Electronically Controlled suspensions system .pdfElectronically Controlled suspensions system .pdf
Electronically Controlled suspensions system .pdfme23b1001
 
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130Suhani Kapoor
 
complete construction, environmental and economics information of biomass com...
complete construction, environmental and economics information of biomass com...complete construction, environmental and economics information of biomass com...
complete construction, environmental and economics information of biomass com...asadnawaz62
 
CCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdf
CCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdfCCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdf
CCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdfAsst.prof M.Gokilavani
 
Past, Present and Future of Generative AI
Past, Present and Future of Generative AIPast, Present and Future of Generative AI
Past, Present and Future of Generative AIabhishek36461
 

Recently uploaded (20)

VICTOR MAESTRE RAMIREZ - Planetary Defender on NASA's Double Asteroid Redirec...
VICTOR MAESTRE RAMIREZ - Planetary Defender on NASA's Double Asteroid Redirec...VICTOR MAESTRE RAMIREZ - Planetary Defender on NASA's Double Asteroid Redirec...
VICTOR MAESTRE RAMIREZ - Planetary Defender on NASA's Double Asteroid Redirec...
 
Biology for Computer Engineers Course Handout.pptx
Biology for Computer Engineers Course Handout.pptxBiology for Computer Engineers Course Handout.pptx
Biology for Computer Engineers Course Handout.pptx
 
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptxDecoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
 
Current Transformer Drawing and GTP for MSETCL
Current Transformer Drawing and GTP for MSETCLCurrent Transformer Drawing and GTP for MSETCL
Current Transformer Drawing and GTP for MSETCL
 
🔝9953056974🔝!!-YOUNG call girls in Rajendra Nagar Escort rvice Shot 2000 nigh...
🔝9953056974🔝!!-YOUNG call girls in Rajendra Nagar Escort rvice Shot 2000 nigh...🔝9953056974🔝!!-YOUNG call girls in Rajendra Nagar Escort rvice Shot 2000 nigh...
🔝9953056974🔝!!-YOUNG call girls in Rajendra Nagar Escort rvice Shot 2000 nigh...
 
IVE Industry Focused Event - Defence Sector 2024
IVE Industry Focused Event - Defence Sector 2024IVE Industry Focused Event - Defence Sector 2024
IVE Industry Focused Event - Defence Sector 2024
 
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdf
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdfCCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdf
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdf
 
Artificial-Intelligence-in-Electronics (K).pptx
Artificial-Intelligence-in-Electronics (K).pptxArtificial-Intelligence-in-Electronics (K).pptx
Artificial-Intelligence-in-Electronics (K).pptx
 
INFLUENCE OF NANOSILICA ON THE PROPERTIES OF CONCRETE
INFLUENCE OF NANOSILICA ON THE PROPERTIES OF CONCRETEINFLUENCE OF NANOSILICA ON THE PROPERTIES OF CONCRETE
INFLUENCE OF NANOSILICA ON THE PROPERTIES OF CONCRETE
 
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICSAPPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
 
Call Girls Narol 7397865700 Independent Call Girls
Call Girls Narol 7397865700 Independent Call GirlsCall Girls Narol 7397865700 Independent Call Girls
Call Girls Narol 7397865700 Independent Call Girls
 
Design and analysis of solar grass cutter.pdf
Design and analysis of solar grass cutter.pdfDesign and analysis of solar grass cutter.pdf
Design and analysis of solar grass cutter.pdf
 
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
 
Electronically Controlled suspensions system .pdf
Electronically Controlled suspensions system .pdfElectronically Controlled suspensions system .pdf
Electronically Controlled suspensions system .pdf
 
Call Us -/9953056974- Call Girls In Vikaspuri-/- Delhi NCR
Call Us -/9953056974- Call Girls In Vikaspuri-/- Delhi NCRCall Us -/9953056974- Call Girls In Vikaspuri-/- Delhi NCR
Call Us -/9953056974- Call Girls In Vikaspuri-/- Delhi NCR
 
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
 
complete construction, environmental and economics information of biomass com...
complete construction, environmental and economics information of biomass com...complete construction, environmental and economics information of biomass com...
complete construction, environmental and economics information of biomass com...
 
CCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdf
CCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdfCCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdf
CCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdf
 
9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf
9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf
9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf
 
Past, Present and Future of Generative AI
Past, Present and Future of Generative AIPast, Present and Future of Generative AI
Past, Present and Future of Generative AI
 

Chapter4.pptx

  • 1. 0  Outline: ◦ Definition of Structures ◦ Array of structures ◦ Structure and functions ◦ Enumerated data type
  • 2.  A structure in C++ are a group of data elements grouped together under one name. these data elements known as a member of a structure.  A structure type in C++ is called struct.  A struct is heterogeneous in that it can be composed of data of different types.  In contrast, array is homogeneous since it can contain only data of the same type. 1
  • 3.  Unlike an array, a structure can contain many different data types (int, string, bool, etc.).  Structures hold data that belong together.  Examples: ◦ Student record: student id, name, major, gender, start year, … ◦ Bank account: account number, name, currency, balance, … ◦ Address book: name, address, telephone number, …  In database applications, structures are called records.  Individual components of a struct type are called members (or fields). 2
  • 4.  Members can be of different types (simple, array or struct).  A struct is named as a whole while individual members are named using field identifiers.  Complex data structures can be formed by defining arrays of structs. 3
  • 5.  The keyword ‘struct ‘ is used for creating a structure.  The structure declaration appears at the top of the source code file before any variables and structures are defined.  Then inside the curly braces, you can declare one or more members (declare variables inside curly braces) of that structure. For example:  Definition of a structure: struct structure_name { data-type member-1; data-type member-2; data-type member-3; data-type member-4; } ; 4  Example: struct Date { int day; int month; int year; } ; The “Date” structure has 3 members, day, month & year. Notice the required ;
  • 6. 5  Example: struct StudentInfo{ int Id; int age; char Gender; double CGPA; };  Example: struct StudentGrade{ char Name[15]; char Course[9]; int Lab[5]; int Homework[3]; int Exam[2]; }; The “StudentInfo” structure has 4 members of different types. The “StudentGrade” structure has 5 members of different array types.
  • 7.  struct names commonly begin with an uppercase letter  Multiple fields of same type can be in a comma- separated list. string name,address; 6 The “Person” structure has 3 members of different types.
  • 8. 7  Struct declaration does not allocate memory or create variables.  To allocate memory spaces for structure members, we must create an object which is called structure variable. Let’s create a structure having 3 variable a, b, c. Method 1: struct structure_name { member definition; member definition; ... member definition; } ; struct structure_name a,b,c;
  • 9. 8 Method 2: struct structure_name { member definition; member definition; ... member definition; } ; structure_name a,b,c; Method 3 struct structure_name { member definition; member definition; ... member definition; }a,b,c ;
  • 10.  To access any member of a structure, we use the member access operator (.). The member access operator is coded as a period between the structure variable name and the structure member that we wish to access. ◦ structure variable name. structure member 9 p.name; is char array element of structure p. p.age; is the integer element of structure p. p.salary; is a float element of structure p. The “Person” structure has 3 members of different types. name age salary Person name age salary p
  • 11.  To display the contents of a struct variable, you must display each field separately, using the dot operator struct Student { int studentID; string name; short year; double gpa; }; Student s1; cout << s1; // won’t work! cout << s1.studentID << endl; cout << s1.name << endl; cout << s1.year << endl; cout << s1.gpa; 10 Wrong: Correct
  • 12. 11  Cannot initialize members in the structure declaration, because no memory has been allocated yet. struct Student // Illegal { //initialization int studentID = 1145; string name = "Alex"; short year = 1; float gpa = 2.95; };
  • 13. 12  Structure members are initialized at the time a structure variable is created.  Can initialize a structure variable’s members with either ◦ an initialization list ◦ a constructor  An initialization list is an ordered set of values, separated by commas and contained in { }, that provides initial values for a set of data members. {12, 6, 3} // initialization list // with 3 values
  • 14. 13  Order of list elements matters: The first value initializes the first data member, the second value initializes the second data member, etc.  Elements of an initialization list can be constants, variables, or expressions. {12, W, L/W + 1} // initialization //List with 3 items
  • 15. 14 Initialization list example: struct Dimensions { int length, int width, int height; }; Dimensions box = {12,6,3}; box length 12 width 6 height 3  Can initialize just some members, but cannot skip over members. Dimensions box1 = {12,6}; //OK Dimensions box2 = {12,,3}; //illegal  Can’t omit a value for a member without omitting values for all following members.
  • 16. 15 C++ Program to assign data to members of a structure variable and display it. Output Enter Full name: abebe kebede Enter age: 27 Enter salary: 1024.4 Displaying Information. Name: abebe kebede Age: 27 Salary: 1024.4
  • 17.  We can create an array of structures. thus we can use the same structure for more than one variable which adds more flexibility to your program.  In another word array of structure means making the structure variable an array.  suppose we need to store the data of 100 students. Declaring 100 separate variables of the structure is definitely not a good option. For that, we need to create an array of structures. 16
  • 19.  We can also create an object of a structure in another structure as members of a structure.  If you have data like student information (name, id, age, section), and the address of a person (kebele, kefle-Ketama, and road name). what are you going to do? You must be able to incorporate this type of data in other structs. The following program declares two structs one for address and the other for students. 18
  • 20. 19
  • 21.  Structure variables can be passed to a function and returned in a similar way as normal arguments.  There are two methods by which we can pass structures to functions. • Passing by Value • Passing by Reference  The call/pass-by value method of passing arguments to a function, copies the actual value of an argument into the formal parameter of the function.  In this case changes made to the parameter inside the function have no effect on the argument.  By default, C++ uses call-by-value to pass arguments. In general, this means that code within a function cannot alter the arguments used to call the function. 20
  • 22.  The call/pass by reference method of passing arguments to a function, copies the reference of an argument into the formal parameter.  Inside the function, the reference is used to access the actual argument used in the call. this means that changes made to the parameter affect the passed arguments.  To pass the value by reference, argument reference is passed to the functions just like any other value. 21
  • 23. 22
  • 24. 23
  • 25. 24
  • 26. 25
  • 27.  An enumeration is a user-defined data type that consists of integral constants.  Enums or enumerations are generally used when you expect the variable to select one value from the possible set of values.  To define an enumeration, the keyword enum is used. 26
  • 28. 27 By default, spring is 0, summer is 1 and so on. You can change the default value of an enum element during declaration (if necessary).
  • 30. 29