SlideShare a Scribd company logo
The differences between structure and class
AGENDA
Whatisstructure?
WhatisdifferencebetweenCandC++structure?
Whatisclass?
Whatarethesimilaritiesbetween structureandclass?
Whatarethedifferencesbetweenstructureandclass?
Questionsorsuggestions
Structure is a user defined data type which is a collection of simple variables
these variables can be of different types such as int,float,char and so on the
difference between structure and array is in this point that array is also the
collection of simple data types but array is the collection of the same data
types and struct is the collection of different kinds of data types.
 each structure must be defined first after that we can create it’s objects in
another functions such as in main().
C structure
 Only variable of different data types can be created functions are not allowed.
 Use of ‘struct’ keyword is necessary while declaring the objects of the structure.
 Member variables cannot be initialized inside the structure.
 We can’t use the static members in c structures .
 Only pointer can be used as the part of the C structure reference is not allowed.
 The compiler gives the size 0 to an empty structure and in C.
 C doesn't allow data hiding in structure.
 C structures don’t know the access modifiers.
C++ structure
 We can use both member variables and member functions in C++.
 C++ also have .* and -> operators to access individual members of struct, but C
doesn't have such kind of operators.
 The compiler gives the size 1 to an empty structure in C++.
 C++ allows the concept of data hiding in structure.
 C++ structure have access modifiers as these are included in the structure of this
language.
 We can use static members inside a C++ structure.
 We can initialize a structure members inside the structure even the C++11 thanks to
the ones who do this work.
Class is also a user defined data type which can
have deferent types of data types and member
functions inside it’s body.
 class is the same as structure but has some
differences with it we will talk about it.
We use the keyword Class for the declaration of the
class.
THE SIMILARITIES BETWEEN STRUCT AND CLASS
You can declare member variable in both.
You can create member functions in both.
You can create objects from both class and structure.
You can create constructor and destructors in both class and
structure.
Inheritance is possible in both class and structure.
You can inherit a structure from a class and do the reverse.
You can use access specifiers In both class and structure.
THE DIFFERENCES BETWEEN CLASS AND
STRUCTURE
Structure:
Key word for the declaration is struct.
Default access specifiers is public.
Purpose :Generally grouping of data.
Usage : generally used for small amount of data.
Type: value.
Storage: object is created on the stack memory.
It can have only parameterized constructors and destructors.
Class :
Key word for the declaration is class.
Default access specifiers is private.
Purpose: data abstraction and further inheritance.
Usage: generally used for large amount of data.
Type: reference .
Storage : object is created on the heap memory.
It can have all types of constructors and destructors.
Class :
In class inheritance the default access specifiers is private.
But
In structure inheritance the default access specifiers is
public.
QUESTIONS OR
SUGGESTIONS

More Related Content

What's hot

File in C language
File in C languageFile in C language
File in C language
Manash Kumar Mondal
 
Operators in java
Operators in javaOperators in java
Operators in java
yugandhar vadlamudi
 
C Structures & Unions
C Structures & UnionsC Structures & Unions
C Structures & Unions
Ram Sagar Mourya
 
Inheritance in C++
Inheritance in C++Inheritance in C++
Inheritance in C++
Laxman Puri
 
07. Virtual Functions
07. Virtual Functions07. Virtual Functions
07. Virtual Functions
Haresh Jaiswal
 
Static keyword ppt
Static keyword pptStatic keyword ppt
Static keyword ppt
Vinod Kumar
 
Inheritance In C++ (Object Oriented Programming)
Inheritance In C++ (Object Oriented Programming)Inheritance In C++ (Object Oriented Programming)
Inheritance In C++ (Object Oriented Programming)
Gajendra Singh Thakur
 
Inline function in C++
Inline function in C++Inline function in C++
Inline function in C++
Learn By Watch
 
Static Data Members and Member Functions
Static Data Members and Member FunctionsStatic Data Members and Member Functions
Static Data Members and Member Functions
MOHIT AGARWAL
 
Class and object in C++
Class and object in C++Class and object in C++
Class and object in C++
rprajat007
 
Control structures in java
Control structures in javaControl structures in java
Control structures in java
VINOTH R
 
Tokens expressionsin C++
Tokens expressionsin C++Tokens expressionsin C++
Tokens expressionsin C++
HalaiHansaika
 
Nested structure (Computer programming and utilization)
Nested structure (Computer programming and utilization)Nested structure (Computer programming and utilization)
Nested structure (Computer programming and utilization)
Digvijaysinh Gohil
 
class and objects
class and objectsclass and objects
class and objectsPayel Guria
 
Data types in c++
Data types in c++Data types in c++
Data types in c++
Venkata.Manish Reddy
 
Constructor and Types of Constructors
Constructor and Types of ConstructorsConstructor and Types of Constructors
Constructor and Types of Constructors
Dhrumil Panchal
 
Structures in c language
Structures in c languageStructures in c language
Structures in c language
tanmaymodi4
 
Constructors and destructors
Constructors and destructorsConstructors and destructors
Constructors and destructors
Nilesh Dalvi
 
Functions in c language
Functions in c language Functions in c language
Functions in c language
tanmaymodi4
 

What's hot (20)

File in C language
File in C languageFile in C language
File in C language
 
Operators in java
Operators in javaOperators in java
Operators in java
 
C Structures & Unions
C Structures & UnionsC Structures & Unions
C Structures & Unions
 
Inheritance in C++
Inheritance in C++Inheritance in C++
Inheritance in C++
 
07. Virtual Functions
07. Virtual Functions07. Virtual Functions
07. Virtual Functions
 
Static keyword ppt
Static keyword pptStatic keyword ppt
Static keyword ppt
 
Inheritance In C++ (Object Oriented Programming)
Inheritance In C++ (Object Oriented Programming)Inheritance In C++ (Object Oriented Programming)
Inheritance In C++ (Object Oriented Programming)
 
Sql operators & functions 3
Sql operators & functions 3Sql operators & functions 3
Sql operators & functions 3
 
Inline function in C++
Inline function in C++Inline function in C++
Inline function in C++
 
Static Data Members and Member Functions
Static Data Members and Member FunctionsStatic Data Members and Member Functions
Static Data Members and Member Functions
 
Class and object in C++
Class and object in C++Class and object in C++
Class and object in C++
 
Control structures in java
Control structures in javaControl structures in java
Control structures in java
 
Tokens expressionsin C++
Tokens expressionsin C++Tokens expressionsin C++
Tokens expressionsin C++
 
Nested structure (Computer programming and utilization)
Nested structure (Computer programming and utilization)Nested structure (Computer programming and utilization)
Nested structure (Computer programming and utilization)
 
class and objects
class and objectsclass and objects
class and objects
 
Data types in c++
Data types in c++Data types in c++
Data types in c++
 
Constructor and Types of Constructors
Constructor and Types of ConstructorsConstructor and Types of Constructors
Constructor and Types of Constructors
 
Structures in c language
Structures in c languageStructures in c language
Structures in c language
 
Constructors and destructors
Constructors and destructorsConstructors and destructors
Constructors and destructors
 
Functions in c language
Functions in c language Functions in c language
Functions in c language
 

Similar to struct and class deferences

Class-١.pptx vbdbbdndgngngndngnnfndfnngn
Class-١.pptx vbdbbdndgngngndngnnfndfnngnClass-١.pptx vbdbbdndgngngndngnnfndfnngn
Class-١.pptx vbdbbdndgngngndngnnfndfnngn
YoussefSameh20
 
Programming in C
Programming in CProgramming in C
Programming in C
MalathiNagarajan20
 
Presentation on c programing satcture
Presentation on c programing satcture Presentation on c programing satcture
Presentation on c programing satcture
topu93
 
Presentation on c structures
Presentation on c   structures Presentation on c   structures
Presentation on c structures
topu93
 
Unit 3
Unit 3Unit 3
Unit 3
TPLatchoumi
 
C# program structure
C# program structureC# program structure
Lk module4 structures
Lk module4 structuresLk module4 structures
Lk module4 structures
Krishna Nanda
 
4 Classes & Objects
4 Classes & Objects4 Classes & Objects
4 Classes & Objects
Praveen M Jigajinni
 
Structures
StructuresStructures
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
Abhishekkumarsingh630054
 
Chapter4.pptx
Chapter4.pptxChapter4.pptx
Chapter4.pptx
WondimuBantihun1
 
Advanced CPP Lecture 1- Summer School 2014 - ACA CSE IITK
Advanced CPP Lecture 1- Summer School 2014 - ACA CSE IITKAdvanced CPP Lecture 1- Summer School 2014 - ACA CSE IITK
Advanced CPP Lecture 1- Summer School 2014 - ACA CSE IITKPankaj Prateek
 
STRUCTURE AND UNION IN C MRS.SOWMYA JYOTHI.pdf
STRUCTURE AND UNION IN C MRS.SOWMYA JYOTHI.pdfSTRUCTURE AND UNION IN C MRS.SOWMYA JYOTHI.pdf
STRUCTURE AND UNION IN C MRS.SOWMYA JYOTHI.pdf
SowmyaJyothi3
 
Structures in c++
Structures in c++Structures in c++
Structures in c++
Swarup Boro
 
Classes, objects and methods
Classes, objects and methodsClasses, objects and methods
Classes, objects and methodsfarhan amjad
 
Structure & union
Structure & unionStructure & union
Structure & union
lalithambiga kamaraj
 
Learn C# Programming - Classes & Inheritance
Learn C# Programming - Classes & InheritanceLearn C# Programming - Classes & Inheritance
Learn C# Programming - Classes & Inheritance
Eng Teong Cheah
 

Similar to struct and class deferences (20)

Class-١.pptx vbdbbdndgngngndngnnfndfnngn
Class-١.pptx vbdbbdndgngngndngnnfndfnngnClass-١.pptx vbdbbdndgngngndngnnfndfnngn
Class-١.pptx vbdbbdndgngngndngnnfndfnngn
 
Programming in C
Programming in CProgramming in C
Programming in C
 
Presentation on c programing satcture
Presentation on c programing satcture Presentation on c programing satcture
Presentation on c programing satcture
 
Presentation on c structures
Presentation on c   structures Presentation on c   structures
Presentation on c structures
 
Unit 3
Unit 3Unit 3
Unit 3
 
C# program structure
C# program structureC# program structure
C# program structure
 
Lk module4 structures
Lk module4 structuresLk module4 structures
Lk module4 structures
 
4 Classes & Objects
4 Classes & Objects4 Classes & Objects
4 Classes & Objects
 
Structures
StructuresStructures
Structures
 
Structures in c++
Structures in c++Structures in c++
Structures in c++
 
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
 
Objects and Types C#
Objects and Types C#Objects and Types C#
Objects and Types C#
 
Chapter4.pptx
Chapter4.pptxChapter4.pptx
Chapter4.pptx
 
Advanced CPP Lecture 1- Summer School 2014 - ACA CSE IITK
Advanced CPP Lecture 1- Summer School 2014 - ACA CSE IITKAdvanced CPP Lecture 1- Summer School 2014 - ACA CSE IITK
Advanced CPP Lecture 1- Summer School 2014 - ACA CSE IITK
 
STRUCTURE AND UNION IN C MRS.SOWMYA JYOTHI.pdf
STRUCTURE AND UNION IN C MRS.SOWMYA JYOTHI.pdfSTRUCTURE AND UNION IN C MRS.SOWMYA JYOTHI.pdf
STRUCTURE AND UNION IN C MRS.SOWMYA JYOTHI.pdf
 
My c++
My c++My c++
My c++
 
Structures in c++
Structures in c++Structures in c++
Structures in c++
 
Classes, objects and methods
Classes, objects and methodsClasses, objects and methods
Classes, objects and methods
 
Structure & union
Structure & unionStructure & union
Structure & union
 
Learn C# Programming - Classes & Inheritance
Learn C# Programming - Classes & InheritanceLearn C# Programming - Classes & Inheritance
Learn C# Programming - Classes & Inheritance
 

Recently uploaded

Unbalanced Three Phase Systems and circuits.pptx
Unbalanced Three Phase Systems and circuits.pptxUnbalanced Three Phase Systems and circuits.pptx
Unbalanced Three Phase Systems and circuits.pptx
ChristineTorrepenida1
 
BPV-GUI-01-Guide-for-ASME-Review-Teams-(General)-10-10-2023.pdf
BPV-GUI-01-Guide-for-ASME-Review-Teams-(General)-10-10-2023.pdfBPV-GUI-01-Guide-for-ASME-Review-Teams-(General)-10-10-2023.pdf
BPV-GUI-01-Guide-for-ASME-Review-Teams-(General)-10-10-2023.pdf
MIGUELANGEL966976
 
Nuclear Power Economics and Structuring 2024
Nuclear Power Economics and Structuring 2024Nuclear Power Economics and Structuring 2024
Nuclear Power Economics and Structuring 2024
Massimo Talia
 
KuberTENes Birthday Bash Guadalajara - K8sGPT first impressions
KuberTENes Birthday Bash Guadalajara - K8sGPT first impressionsKuberTENes Birthday Bash Guadalajara - K8sGPT first impressions
KuberTENes Birthday Bash Guadalajara - K8sGPT first impressions
Victor Morales
 
哪里办理(csu毕业证书)查尔斯特大学毕业证硕士学历原版一模一样
哪里办理(csu毕业证书)查尔斯特大学毕业证硕士学历原版一模一样哪里办理(csu毕业证书)查尔斯特大学毕业证硕士学历原版一模一样
哪里办理(csu毕业证书)查尔斯特大学毕业证硕士学历原版一模一样
insn4465
 
NO1 Uk best vashikaran specialist in delhi vashikaran baba near me online vas...
NO1 Uk best vashikaran specialist in delhi vashikaran baba near me online vas...NO1 Uk best vashikaran specialist in delhi vashikaran baba near me online vas...
NO1 Uk best vashikaran specialist in delhi vashikaran baba near me online vas...
Amil Baba Dawood bangali
 
Water billing management system project report.pdf
Water billing management system project report.pdfWater billing management system project report.pdf
Water billing management system project report.pdf
Kamal Acharya
 
basic-wireline-operations-course-mahmoud-f-radwan.pdf
basic-wireline-operations-course-mahmoud-f-radwan.pdfbasic-wireline-operations-course-mahmoud-f-radwan.pdf
basic-wireline-operations-course-mahmoud-f-radwan.pdf
NidhalKahouli2
 
PROJECT FORMAT FOR EVS AMITY UNIVERSITY GWALIOR.ppt
PROJECT FORMAT FOR EVS AMITY UNIVERSITY GWALIOR.pptPROJECT FORMAT FOR EVS AMITY UNIVERSITY GWALIOR.ppt
PROJECT FORMAT FOR EVS AMITY UNIVERSITY GWALIOR.ppt
bhadouriyakaku
 
sieving analysis and results interpretation
sieving analysis and results interpretationsieving analysis and results interpretation
sieving analysis and results interpretation
ssuser36d3051
 
Fundamentals of Electric Drives and its applications.pptx
Fundamentals of Electric Drives and its applications.pptxFundamentals of Electric Drives and its applications.pptx
Fundamentals of Electric Drives and its applications.pptx
manasideore6
 
一比一原版(IIT毕业证)伊利诺伊理工大学毕业证成绩单专业办理
一比一原版(IIT毕业证)伊利诺伊理工大学毕业证成绩单专业办理一比一原版(IIT毕业证)伊利诺伊理工大学毕业证成绩单专业办理
一比一原版(IIT毕业证)伊利诺伊理工大学毕业证成绩单专业办理
zwunae
 
Hierarchical Digital Twin of a Naval Power System
Hierarchical Digital Twin of a Naval Power SystemHierarchical Digital Twin of a Naval Power System
Hierarchical Digital Twin of a Naval Power System
Kerry Sado
 
[JPP-1] - (JEE 3.0) - Kinematics 1D - 14th May..pdf
[JPP-1] - (JEE 3.0) - Kinematics 1D - 14th May..pdf[JPP-1] - (JEE 3.0) - Kinematics 1D - 14th May..pdf
[JPP-1] - (JEE 3.0) - Kinematics 1D - 14th May..pdf
awadeshbabu
 
Swimming pool mechanical components design.pptx
Swimming pool  mechanical components design.pptxSwimming pool  mechanical components design.pptx
Swimming pool mechanical components design.pptx
yokeleetan1
 
在线办理(ANU毕业证书)澳洲国立大学毕业证录取通知书一模一样
在线办理(ANU毕业证书)澳洲国立大学毕业证录取通知书一模一样在线办理(ANU毕业证书)澳洲国立大学毕业证录取通知书一模一样
在线办理(ANU毕业证书)澳洲国立大学毕业证录取通知书一模一样
obonagu
 
Design and Analysis of Algorithms-DP,Backtracking,Graphs,B&B
Design and Analysis of Algorithms-DP,Backtracking,Graphs,B&BDesign and Analysis of Algorithms-DP,Backtracking,Graphs,B&B
Design and Analysis of Algorithms-DP,Backtracking,Graphs,B&B
Sreedhar Chowdam
 
Harnessing WebAssembly for Real-time Stateless Streaming Pipelines
Harnessing WebAssembly for Real-time Stateless Streaming PipelinesHarnessing WebAssembly for Real-time Stateless Streaming Pipelines
Harnessing WebAssembly for Real-time Stateless Streaming Pipelines
Christina Lin
 
NUMERICAL SIMULATIONS OF HEAT AND MASS TRANSFER IN CONDENSING HEAT EXCHANGERS...
NUMERICAL SIMULATIONS OF HEAT AND MASS TRANSFER IN CONDENSING HEAT EXCHANGERS...NUMERICAL SIMULATIONS OF HEAT AND MASS TRANSFER IN CONDENSING HEAT EXCHANGERS...
NUMERICAL SIMULATIONS OF HEAT AND MASS TRANSFER IN CONDENSING HEAT EXCHANGERS...
ssuser7dcef0
 
Building Electrical System Design & Installation
Building Electrical System Design & InstallationBuilding Electrical System Design & Installation
Building Electrical System Design & Installation
symbo111
 

Recently uploaded (20)

Unbalanced Three Phase Systems and circuits.pptx
Unbalanced Three Phase Systems and circuits.pptxUnbalanced Three Phase Systems and circuits.pptx
Unbalanced Three Phase Systems and circuits.pptx
 
BPV-GUI-01-Guide-for-ASME-Review-Teams-(General)-10-10-2023.pdf
BPV-GUI-01-Guide-for-ASME-Review-Teams-(General)-10-10-2023.pdfBPV-GUI-01-Guide-for-ASME-Review-Teams-(General)-10-10-2023.pdf
BPV-GUI-01-Guide-for-ASME-Review-Teams-(General)-10-10-2023.pdf
 
Nuclear Power Economics and Structuring 2024
Nuclear Power Economics and Structuring 2024Nuclear Power Economics and Structuring 2024
Nuclear Power Economics and Structuring 2024
 
KuberTENes Birthday Bash Guadalajara - K8sGPT first impressions
KuberTENes Birthday Bash Guadalajara - K8sGPT first impressionsKuberTENes Birthday Bash Guadalajara - K8sGPT first impressions
KuberTENes Birthday Bash Guadalajara - K8sGPT first impressions
 
哪里办理(csu毕业证书)查尔斯特大学毕业证硕士学历原版一模一样
哪里办理(csu毕业证书)查尔斯特大学毕业证硕士学历原版一模一样哪里办理(csu毕业证书)查尔斯特大学毕业证硕士学历原版一模一样
哪里办理(csu毕业证书)查尔斯特大学毕业证硕士学历原版一模一样
 
NO1 Uk best vashikaran specialist in delhi vashikaran baba near me online vas...
NO1 Uk best vashikaran specialist in delhi vashikaran baba near me online vas...NO1 Uk best vashikaran specialist in delhi vashikaran baba near me online vas...
NO1 Uk best vashikaran specialist in delhi vashikaran baba near me online vas...
 
Water billing management system project report.pdf
Water billing management system project report.pdfWater billing management system project report.pdf
Water billing management system project report.pdf
 
basic-wireline-operations-course-mahmoud-f-radwan.pdf
basic-wireline-operations-course-mahmoud-f-radwan.pdfbasic-wireline-operations-course-mahmoud-f-radwan.pdf
basic-wireline-operations-course-mahmoud-f-radwan.pdf
 
PROJECT FORMAT FOR EVS AMITY UNIVERSITY GWALIOR.ppt
PROJECT FORMAT FOR EVS AMITY UNIVERSITY GWALIOR.pptPROJECT FORMAT FOR EVS AMITY UNIVERSITY GWALIOR.ppt
PROJECT FORMAT FOR EVS AMITY UNIVERSITY GWALIOR.ppt
 
sieving analysis and results interpretation
sieving analysis and results interpretationsieving analysis and results interpretation
sieving analysis and results interpretation
 
Fundamentals of Electric Drives and its applications.pptx
Fundamentals of Electric Drives and its applications.pptxFundamentals of Electric Drives and its applications.pptx
Fundamentals of Electric Drives and its applications.pptx
 
一比一原版(IIT毕业证)伊利诺伊理工大学毕业证成绩单专业办理
一比一原版(IIT毕业证)伊利诺伊理工大学毕业证成绩单专业办理一比一原版(IIT毕业证)伊利诺伊理工大学毕业证成绩单专业办理
一比一原版(IIT毕业证)伊利诺伊理工大学毕业证成绩单专业办理
 
Hierarchical Digital Twin of a Naval Power System
Hierarchical Digital Twin of a Naval Power SystemHierarchical Digital Twin of a Naval Power System
Hierarchical Digital Twin of a Naval Power System
 
[JPP-1] - (JEE 3.0) - Kinematics 1D - 14th May..pdf
[JPP-1] - (JEE 3.0) - Kinematics 1D - 14th May..pdf[JPP-1] - (JEE 3.0) - Kinematics 1D - 14th May..pdf
[JPP-1] - (JEE 3.0) - Kinematics 1D - 14th May..pdf
 
Swimming pool mechanical components design.pptx
Swimming pool  mechanical components design.pptxSwimming pool  mechanical components design.pptx
Swimming pool mechanical components design.pptx
 
在线办理(ANU毕业证书)澳洲国立大学毕业证录取通知书一模一样
在线办理(ANU毕业证书)澳洲国立大学毕业证录取通知书一模一样在线办理(ANU毕业证书)澳洲国立大学毕业证录取通知书一模一样
在线办理(ANU毕业证书)澳洲国立大学毕业证录取通知书一模一样
 
Design and Analysis of Algorithms-DP,Backtracking,Graphs,B&B
Design and Analysis of Algorithms-DP,Backtracking,Graphs,B&BDesign and Analysis of Algorithms-DP,Backtracking,Graphs,B&B
Design and Analysis of Algorithms-DP,Backtracking,Graphs,B&B
 
Harnessing WebAssembly for Real-time Stateless Streaming Pipelines
Harnessing WebAssembly for Real-time Stateless Streaming PipelinesHarnessing WebAssembly for Real-time Stateless Streaming Pipelines
Harnessing WebAssembly for Real-time Stateless Streaming Pipelines
 
NUMERICAL SIMULATIONS OF HEAT AND MASS TRANSFER IN CONDENSING HEAT EXCHANGERS...
NUMERICAL SIMULATIONS OF HEAT AND MASS TRANSFER IN CONDENSING HEAT EXCHANGERS...NUMERICAL SIMULATIONS OF HEAT AND MASS TRANSFER IN CONDENSING HEAT EXCHANGERS...
NUMERICAL SIMULATIONS OF HEAT AND MASS TRANSFER IN CONDENSING HEAT EXCHANGERS...
 
Building Electrical System Design & Installation
Building Electrical System Design & InstallationBuilding Electrical System Design & Installation
Building Electrical System Design & Installation
 

struct and class deferences

  • 1.
  • 2.
  • 3. The differences between structure and class
  • 5. Structure is a user defined data type which is a collection of simple variables these variables can be of different types such as int,float,char and so on the difference between structure and array is in this point that array is also the collection of simple data types but array is the collection of the same data types and struct is the collection of different kinds of data types.  each structure must be defined first after that we can create it’s objects in another functions such as in main().
  • 6.
  • 7.
  • 8. C structure  Only variable of different data types can be created functions are not allowed.  Use of ‘struct’ keyword is necessary while declaring the objects of the structure.  Member variables cannot be initialized inside the structure.  We can’t use the static members in c structures .  Only pointer can be used as the part of the C structure reference is not allowed.  The compiler gives the size 0 to an empty structure and in C.  C doesn't allow data hiding in structure.  C structures don’t know the access modifiers.
  • 9. C++ structure  We can use both member variables and member functions in C++.  C++ also have .* and -> operators to access individual members of struct, but C doesn't have such kind of operators.  The compiler gives the size 1 to an empty structure in C++.  C++ allows the concept of data hiding in structure.  C++ structure have access modifiers as these are included in the structure of this language.  We can use static members inside a C++ structure.  We can initialize a structure members inside the structure even the C++11 thanks to the ones who do this work.
  • 10. Class is also a user defined data type which can have deferent types of data types and member functions inside it’s body.  class is the same as structure but has some differences with it we will talk about it. We use the keyword Class for the declaration of the class.
  • 11.
  • 12.
  • 13. THE SIMILARITIES BETWEEN STRUCT AND CLASS You can declare member variable in both. You can create member functions in both. You can create objects from both class and structure. You can create constructor and destructors in both class and structure. Inheritance is possible in both class and structure. You can inherit a structure from a class and do the reverse. You can use access specifiers In both class and structure.
  • 14. THE DIFFERENCES BETWEEN CLASS AND STRUCTURE
  • 15. Structure: Key word for the declaration is struct. Default access specifiers is public. Purpose :Generally grouping of data. Usage : generally used for small amount of data. Type: value. Storage: object is created on the stack memory. It can have only parameterized constructors and destructors.
  • 16. Class : Key word for the declaration is class. Default access specifiers is private. Purpose: data abstraction and further inheritance. Usage: generally used for large amount of data. Type: reference . Storage : object is created on the heap memory. It can have all types of constructors and destructors.
  • 17. Class : In class inheritance the default access specifiers is private. But In structure inheritance the default access specifiers is public.
  • 18.