SlideShare a Scribd company logo
1 of 62
Download to read offline
Kinan keshkeh 
IT Engineering-Damascus University 
3rd year 
Summer course- 2014 
2 bytes team
Welcome guys !
Smashing C++ !!
Classes & Structures
Structures !
Structures 
•Holds pieces of data
Structures 
•Holds pieces of data
Structures 
•Holds pieces of data 
struct structName{ 
……….members 
…….. 
} its objects(if any) ;
Structures 
•A member could be from a struct type . 
struct Date{ 
int month; 
int day; 
int year; 
} x,y ; 
struct PersonInfo 
{ 
double height;//in cm 
int weight;//in kg 
Date birthday; 
};
Structures 
•A member could be from a struct type . 
struct Date{ 
int month; 
int day; 
int year; 
} x,y ; 
struct PersonInfo 
{ 
double height;//in cm 
int weight;//in kg 
Date birthday; 
}; 
You can define Like this or like this : Date x,y ;
Structures 
•A member could be from a struct type . 
struct Date{ int month; int day; int year; } x,y ; struct PersonInfo { double height;//in cm int weight;//in kg Date birthday; }; 
Don’t forget comma !
Structures 
struct structName{ 
……….members 
…….. 
} its objects(if any) ; 
….. 
…… 
int main() 
{ 
…. 
} 
•This declaration must be Global , to be seen by all functions.
Structures 
•It’s a type ! So it means : 
struct Date{ 
int month; 
int day; 
int year; 
} 
void get(Date x, int count )
Structures 
struct Date{ 
int month; 
int day; 
int year; 
}; 
Date get (int z , int count ) 
•It’s a type ! So it means :
struct Date{ 
int month; 
int day; 
int year; 
} x,y ; 
struct PersonInfo 
{ 
double height;//in cm 
int weight;//in kg 
Date birthday; 
}; 
Structures 
PersonInfo christoph ; 
christoph.height=170; 
christoph.weight=70; 
christoph.birthday.month=10 ; 
christoph.birthday.day=3 ; 
christoph.birthday.year=1978 ; 
•To reach to its members :
struct Date{ int month; int day; int year; } x,y ; struct PersonInfo { double height;//in cm int weight;//in kg Date birthday; }; 
Structures 
PersonInfo christoph ; 
christoph.height=170; 
christoph.weight=70; 
christoph.birthday.month=10 ; 
christoph.birthday.day=3 ; 
christoph.birthday.year=1978 ; 
•To reach to its members :
Structures 
•Initialize : 
struct Date{ 
int month; 
int day; 
int year; 
} x,y ; 
struct PersonInfo 
{ 
double height;//in cm 
int weight;//in kg 
Date birthday; 
}; 
•Like Arrays
Structures 
•Initialize : 
struct Date{ int month; int day; int year; } x,y ; struct PersonInfo { double height;//in cm int weight;//in kg Date birthday; }; 
•Like Arrays 
•Sequentially
Structures 
•Initialize : 
struct Date{ int month; int day; int year; } x,y ; struct PersonInfo { double height;//in cm int weight;//in kg Date birthday; }; 
•Like Arrays 
•Sequentially 
•PersonInfo
Structures 
•Initialize : 
struct Date{ int month; int day; int year; } x,y ; struct PersonInfo { double height;//in cm int weight;//in kg Date birthday; }; 
•Like Arrays 
•Sequentially 
•PersonInfo 
•height
Structures 
•Initialize : 
struct Date{ int month; int day; int year; } x,y ; struct PersonInfo { double height;//in cm int weight;//in kg Date birthday; }; 
•Like Arrays 
•Sequentially 
•PersonInfo 
•height 
•weight
Structures 
•Initialize : 
struct Date{ int month; int day; int year; } x,y ; struct PersonInfo { double height;//in cm int weight;//in kg Date birthday; }; 
•Like Arrays 
•Sequentially 
•PersonInfo 
•height 
•weight 
•birthday
Structures 
•Initialize : 
struct Date{ int month; int day; int year; } x,y ; struct PersonInfo { double height;//in cm int weight;//in kg Date birthday; }; 
•Like Arrays 
•Sequentially 
•PersonInfo 
•height 
•weight 
•birthday 
•month 
•day 
•year
Structures 
•Initialize : 
struct Date{ int month; int day; int year; } x,y ; struct PersonInfo { double height;//in cm int weight;//in kg Date birthday; }; 
•Like Arrays 
•Sequentially 
•PersonInfo 
•height 
•weight 
•birthday 
•month 
•day 
•year
Structures 
•Initialize : 
struct Date{ int month; int day; int year; } x,y ; struct PersonInfo { double height;//in cm int weight;//in kg Date birthday; }; 
•Like Arrays 
•Sequentially 
•PersonInfo 
•height 
•weight 
•birthday 
•month 
•day 
•year
Structures 
•Initialize : 
struct Date{ int month; int day; int year; } x,y ; struct PersonInfo { double height;//in cm int weight;//in kg Date birthday; }; 
•Like Arrays 
•Sequentially 
•PersonInfo 
•height 
•weight 
•birthday 
•month 
•day 
•year
Structures 
•Initialize : 
struct Date{ int month; int day; int year; } x,y ; struct PersonInfo { double height;//in cm int weight;//in kg Date birthday; }; 
•Like Arrays 
•Sequentially 
•PersonInfo 
•height 
•weight 
•birthday 
•month 
•day 
•year
Structures 
•Initialize : 
struct Date{ int month; int day; int year; } x,y ; struct PersonInfo { double height;//in cm int weight;//in kg Date birthday; }; 
PersonInfo christoph ={170,70, 10,3,1978};
Structures 
•Initialize : 
struct Date{ int month; int day; int year; } x,y ; struct PersonInfo { double height;//in cm int weight;//in kg Date birthday; }; 
PersonInfo christoph ={170,70, 10,3,1978};
Structures 
•Initialize : 
struct Date{ int month; int day; int year; } x,y ; struct PersonInfo { double height;//in cm int weight;//in kg Date birthday; }; 
PersonInfo christoph ={170,70, 10,3,1978};
Structures 
•Initialize : 
struct Date{ int month; int day; int year; } x,y ; struct PersonInfo { double height;//in cm int weight;//in kg Date birthday; }; 
PersonInfo christoph ={170,70, 10,3,1978};
Structures 
•Initialize : 
struct Date{ int month; int day; int year; } x,y ; struct PersonInfo { double height;//in cm int weight;//in kg Date birthday; }; 
PersonInfo christoph ={170,70, 10,3,1978};
Structures 
•Initialize : 
struct Date{ int month; int day; int year; } x,y ; struct PersonInfo { double height;//in cm int weight;//in kg Date birthday; }; 
PersonInfo christoph ={170,70};
Structures 
•Initialize : 
struct Date{ int month; int day; int year; } x,y ; struct PersonInfo { double height;//in cm int weight;//in kg Date birthday; }; 
PersonInfo christoph ={170,70}; 
month=0; 
day=0; 
year=0;
Structures 
•Initialize : 
struct Date{ int month; int day; int year; } x,y ; struct PersonInfo { double height;//in cm int weight;//in kg Date birthday; }; 
PersonInfo christoph ={170,70}; 
month=0; 
day=0; 
year=0;
Structures 
•Initialize : 
struct Date{ int month; int day; int year; } x,y ; struct PersonInfo { double height;//in cm int weight;//in kg Date birthday; }; 
Note : 
Unlike Array , when you initialize , if you pass the number of members ! 
You will have an Error !
& To save the memebers values !
Output:
Classes !
Classes 
•It’s like a Struct. 
•Its members could be Functions and data 
• it supports( information hiding, data abstraction, and encapsulation )
Classes 
•It’s like a Struct. 
•Its members could be Functions and data 
• it supports( information hiding, data abstraction, and encapsulation ) 
•private, only seen in the current class(for class functions) , unseen out of class ! 
• public, seen everywhere (in current class and out of class) 
•We use two things in classes :
Classes 
•It’s like a Struct. 
•Its members could be Functions and data 
• it supports( information hiding, data abstraction, and encapsulation ) 
•Mostly in each class , you might have get(privateto variables )and set(variablesprivate) functions 
•private, only seen in the current class(for class functions) , unseen out of class ! 
• public, seen everywhere (in current class and out of class) 
•We use two things in classes :
Classes 
•Mostly in each class , you might have get(privateto variables )and set(variablesprivate) functions
Classes 
•Mostly in each class , you might have get(privateto variables )and set(variablesprivate) functions 
Accessor functions 
Mutator functions
Classes 
class className{ private: ……….members …….. public: ……….members …….. } ;
Classes 
class className{ private: ……….members …….. public: ……….members …….. } ; 
Don’t forget!
•You can definitions them here ! 
•But it’s better not !
Returned type 
Class name 
“ : : “
•Output:
Classes 
class className{ private: ……….members …….. public: ……….members …….. } ;
Classes 
class className{ int num,den; public: ……….members …….. } ;
Classes 
struct structName{ 
int num,den; 
…members 
…….. 
} ;
Classes 
struct structName{ int num,den; …members …….. } ;
That’s for today 
We’re finished !!
2 bytes team 
Group : group link Mobile phone- Kinan : 0994385748 Facebook account : kinan’s account 
2 bytes team

More Related Content

Viewers also liked

F4 San Jose Construction Rec
F4 San Jose Construction RecF4 San Jose Construction Rec
F4 San Jose Construction Rec
Steve Allen
 
Tecnologías de puntajfhhhh
Tecnologías de puntajfhhhhTecnologías de puntajfhhhh
Tecnologías de puntajfhhhh
sebanico1936
 
F8 Ellis Don Const Uw K Wing
F8 Ellis   Don Const Uw K WingF8 Ellis   Don Const Uw K Wing
F8 Ellis Don Const Uw K Wing
Steve Allen
 
Técnica de eprendizaje por casos
Técnica de eprendizaje por casosTécnica de eprendizaje por casos
Técnica de eprendizaje por casos
mamaangeles
 
ความเป็นมาของคำว่านิติรัฐ
ความเป็นมาของคำว่านิติรัฐความเป็นมาของคำว่านิติรัฐ
ความเป็นมาของคำว่านิติรัฐ
Wac Ert
 
juego de coordenadas 503 esquivel
juego de coordenadas 503 esquiveljuego de coordenadas 503 esquivel
juego de coordenadas 503 esquivel
Gabbi161209
 

Viewers also liked (19)

Teoría
TeoríaTeoría
Teoría
 
Nacho
NachoNacho
Nacho
 
Psique dental
Psique  dentalPsique  dental
Psique dental
 
F4 San Jose Construction Rec
F4 San Jose Construction RecF4 San Jose Construction Rec
F4 San Jose Construction Rec
 
Tecnologías de puntajfhhhh
Tecnologías de puntajfhhhhTecnologías de puntajfhhhh
Tecnologías de puntajfhhhh
 
F8 Ellis Don Const Uw K Wing
F8 Ellis   Don Const Uw K WingF8 Ellis   Don Const Uw K Wing
F8 Ellis Don Const Uw K Wing
 
Pechakucha3
Pechakucha3Pechakucha3
Pechakucha3
 
Técnica de eprendizaje por casos
Técnica de eprendizaje por casosTécnica de eprendizaje por casos
Técnica de eprendizaje por casos
 
Tentaciones LOV Dulces Hipoalergénicos
Tentaciones LOV Dulces HipoalergénicosTentaciones LOV Dulces Hipoalergénicos
Tentaciones LOV Dulces Hipoalergénicos
 
ความเป็นมาของคำว่านิติรัฐ
ความเป็นมาของคำว่านิติรัฐความเป็นมาของคำว่านิติรัฐ
ความเป็นมาของคำว่านิติรัฐ
 
Gi meg et eksempel! Introduksjon til BDD
Gi meg et eksempel! Introduksjon til BDDGi meg et eksempel! Introduksjon til BDD
Gi meg et eksempel! Introduksjon til BDD
 
juego de coordenadas 503 esquivel
juego de coordenadas 503 esquiveljuego de coordenadas 503 esquivel
juego de coordenadas 503 esquivel
 
Paxtu
PaxtuPaxtu
Paxtu
 
4. la derivada
4. la derivada4. la derivada
4. la derivada
 
Ideal vince la gara per la campagna del Teatro Stabile di Torino
Ideal vince la gara per la campagna del Teatro Stabile di TorinoIdeal vince la gara per la campagna del Teatro Stabile di Torino
Ideal vince la gara per la campagna del Teatro Stabile di Torino
 
Fichas
FichasFichas
Fichas
 
Trabajo Colaborativo
Trabajo ColaborativoTrabajo Colaborativo
Trabajo Colaborativo
 
PROYECTO DE REFORMA DE TERRAZA
PROYECTO DE REFORMA DE TERRAZA PROYECTO DE REFORMA DE TERRAZA
PROYECTO DE REFORMA DE TERRAZA
 
Rúbrica de mapa mental
Rúbrica de mapa mentalRúbrica de mapa mental
Rúbrica de mapa mental
 

Similar to 2 BytesC++ course_2014_c5_ structures and classes

Hello. Im working on an assignment that tests inheritance and comp.pdf
Hello. Im working on an assignment that tests inheritance and comp.pdfHello. Im working on an assignment that tests inheritance and comp.pdf
Hello. Im working on an assignment that tests inheritance and comp.pdf
duttakajal70
 
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
Pankaj Prateek
 
Building Single-Page Web Appplications in dart - Devoxx France 2013
Building Single-Page Web Appplications in dart - Devoxx France 2013Building Single-Page Web Appplications in dart - Devoxx France 2013
Building Single-Page Web Appplications in dart - Devoxx France 2013
yohanbeschi
 
Code to copy Person.java .pdf
Code to copy Person.java .pdfCode to copy Person.java .pdf
Code to copy Person.java .pdf
anokhijew
 

Similar to 2 BytesC++ course_2014_c5_ structures and classes (12)

Hello. Im working on an assignment that tests inheritance and comp.pdf
Hello. Im working on an assignment that tests inheritance and comp.pdfHello. Im working on an assignment that tests inheritance and comp.pdf
Hello. Im working on an assignment that tests inheritance and comp.pdf
 
CHAPTER -4-class and structure.pptx
CHAPTER -4-class and structure.pptxCHAPTER -4-class and structure.pptx
CHAPTER -4-class and structure.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
 
05 Java Language And OOP Part V
05 Java Language And OOP Part V05 Java Language And OOP Part V
05 Java Language And OOP Part V
 
Introduction to c ++ part -1
Introduction to c ++   part -1Introduction to c ++   part -1
Introduction to c ++ part -1
 
Intro To C++ - Class #23: Inheritance, Part 2
Intro To C++ - Class #23: Inheritance, Part 2Intro To C++ - Class #23: Inheritance, Part 2
Intro To C++ - Class #23: Inheritance, Part 2
 
C++ training
C++ training C++ training
C++ training
 
Building Single-Page Web Appplications in dart - Devoxx France 2013
Building Single-Page Web Appplications in dart - Devoxx France 2013Building Single-Page Web Appplications in dart - Devoxx France 2013
Building Single-Page Web Appplications in dart - Devoxx France 2013
 
Kotlin Data Model
Kotlin Data ModelKotlin Data Model
Kotlin Data Model
 
Code to copy Person.java .pdf
Code to copy Person.java .pdfCode to copy Person.java .pdf
Code to copy Person.java .pdf
 
Unit 9. Structure and Unions
Unit 9. Structure and UnionsUnit 9. Structure and Unions
Unit 9. Structure and Unions
 
Web development basics (Part-3)
Web development basics (Part-3)Web development basics (Part-3)
Web development basics (Part-3)
 

More from kinan keshkeh

More from kinan keshkeh (20)

10 Little Tricks to Get Your Class’s Attention (and Hold It)
10 Little Tricks to Get Your  Class’s Attention (and Hold It)10 Little Tricks to Get Your  Class’s Attention (and Hold It)
10 Little Tricks to Get Your Class’s Attention (and Hold It)
 
Simpson and lagranje dalambair math methods
Simpson and lagranje dalambair math methods Simpson and lagranje dalambair math methods
Simpson and lagranje dalambair math methods
 
Shapes and calculate (area and contour) / C++ oop concept
Shapes and calculate (area and contour) / C++ oop conceptShapes and calculate (area and contour) / C++ oop concept
Shapes and calculate (area and contour) / C++ oop concept
 
Shapes and calculate (area and contour) / C++ oop concept
Shapes and calculate (area and contour) / C++ oop conceptShapes and calculate (area and contour) / C++ oop concept
Shapes and calculate (area and contour) / C++ oop concept
 
GeneticAlgorithms_AND_CuttingWoodAlgorithm
GeneticAlgorithms_AND_CuttingWoodAlgorithm  GeneticAlgorithms_AND_CuttingWoodAlgorithm
GeneticAlgorithms_AND_CuttingWoodAlgorithm
 
Algorithm in discovering and correcting words errors in a dictionary or any w...
Algorithm in discovering and correcting words errors in a dictionary or any w...Algorithm in discovering and correcting words errors in a dictionary or any w...
Algorithm in discovering and correcting words errors in a dictionary or any w...
 
2Bytesprog2 course_2014_c9_graph
2Bytesprog2 course_2014_c9_graph2Bytesprog2 course_2014_c9_graph
2Bytesprog2 course_2014_c9_graph
 
2Bytesprog2 course_2014_c8_units
2Bytesprog2 course_2014_c8_units2Bytesprog2 course_2014_c8_units
2Bytesprog2 course_2014_c8_units
 
2Bytesprog2 course_2014_c7_double_lists
2Bytesprog2 course_2014_c7_double_lists2Bytesprog2 course_2014_c7_double_lists
2Bytesprog2 course_2014_c7_double_lists
 
2Bytesprog2 course_2014_c6_single linked list
2Bytesprog2 course_2014_c6_single linked list2Bytesprog2 course_2014_c6_single linked list
2Bytesprog2 course_2014_c6_single linked list
 
2Bytesprog2 course_2014_c5_pointers
2Bytesprog2 course_2014_c5_pointers2Bytesprog2 course_2014_c5_pointers
2Bytesprog2 course_2014_c5_pointers
 
2Bytesprog2 course_2014_c4_binaryfiles
2Bytesprog2 course_2014_c4_binaryfiles2Bytesprog2 course_2014_c4_binaryfiles
2Bytesprog2 course_2014_c4_binaryfiles
 
2Bytesprog2 course_2014_c3_txtfiles
2Bytesprog2 course_2014_c3_txtfiles2Bytesprog2 course_2014_c3_txtfiles
2Bytesprog2 course_2014_c3_txtfiles
 
2Bytesprog2 course_2014_c2_records
2Bytesprog2 course_2014_c2_records2Bytesprog2 course_2014_c2_records
2Bytesprog2 course_2014_c2_records
 
2Bytesprog2 course_2014_c1_sets
2Bytesprog2 course_2014_c1_sets2Bytesprog2 course_2014_c1_sets
2Bytesprog2 course_2014_c1_sets
 
2Bytesprog2 course_2014_c1_sets
2Bytesprog2 course_2014_c1_sets2Bytesprog2 course_2014_c1_sets
2Bytesprog2 course_2014_c1_sets
 
2Bytesprog2 course_2014_c1_sets
2Bytesprog2 course_2014_c1_sets2Bytesprog2 course_2014_c1_sets
2Bytesprog2 course_2014_c1_sets
 
2Bytesprog2 course_2014_c1_sets
2Bytesprog2 course_2014_c1_sets2Bytesprog2 course_2014_c1_sets
2Bytesprog2 course_2014_c1_sets
 
2 BytesC++ course_2014_c13_ templates
2 BytesC++ course_2014_c13_ templates2 BytesC++ course_2014_c13_ templates
2 BytesC++ course_2014_c13_ templates
 
2 BytesC++ course_2014_c12_ polymorphism
2 BytesC++ course_2014_c12_ polymorphism2 BytesC++ course_2014_c12_ polymorphism
2 BytesC++ course_2014_c12_ polymorphism
 

Recently uploaded

Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...
Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...
Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...
chiefasafspells
 
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
Medical / Health Care (+971588192166) Mifepristone and Misoprostol tablets 200mg
 
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
masabamasaba
 
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
masabamasaba
 

Recently uploaded (20)

%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
 
AI & Machine Learning Presentation Template
AI & Machine Learning Presentation TemplateAI & Machine Learning Presentation Template
AI & Machine Learning Presentation Template
 
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
 
What Goes Wrong with Language Definitions and How to Improve the Situation
What Goes Wrong with Language Definitions and How to Improve the SituationWhat Goes Wrong with Language Definitions and How to Improve the Situation
What Goes Wrong with Language Definitions and How to Improve the Situation
 
Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...
Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...
Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...
 
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital TransformationWSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
 
WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...
WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...
WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...
 
%in Benoni+277-882-255-28 abortion pills for sale in Benoni
%in Benoni+277-882-255-28 abortion pills for sale in Benoni%in Benoni+277-882-255-28 abortion pills for sale in Benoni
%in Benoni+277-882-255-28 abortion pills for sale in Benoni
 
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
 
Payment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdf
Payment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdfPayment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdf
Payment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdf
 
WSO2CON2024 - It's time to go Platformless
WSO2CON2024 - It's time to go PlatformlessWSO2CON2024 - It's time to go Platformless
WSO2CON2024 - It's time to go Platformless
 
WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...
WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...
WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...
 
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
 
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
 
tonesoftg
tonesoftgtonesoftg
tonesoftg
 
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
 
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
 
8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech students8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech students
 
Microsoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdfMicrosoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdf
 
%in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park %in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park
 

2 BytesC++ course_2014_c5_ structures and classes

  • 1. Kinan keshkeh IT Engineering-Damascus University 3rd year Summer course- 2014 2 bytes team
  • 8. Structures •Holds pieces of data struct structName{ ……….members …….. } its objects(if any) ;
  • 9. Structures •A member could be from a struct type . struct Date{ int month; int day; int year; } x,y ; struct PersonInfo { double height;//in cm int weight;//in kg Date birthday; };
  • 10. Structures •A member could be from a struct type . struct Date{ int month; int day; int year; } x,y ; struct PersonInfo { double height;//in cm int weight;//in kg Date birthday; }; You can define Like this or like this : Date x,y ;
  • 11. Structures •A member could be from a struct type . struct Date{ int month; int day; int year; } x,y ; struct PersonInfo { double height;//in cm int weight;//in kg Date birthday; }; Don’t forget comma !
  • 12. Structures struct structName{ ……….members …….. } its objects(if any) ; ….. …… int main() { …. } •This declaration must be Global , to be seen by all functions.
  • 13. Structures •It’s a type ! So it means : struct Date{ int month; int day; int year; } void get(Date x, int count )
  • 14. Structures struct Date{ int month; int day; int year; }; Date get (int z , int count ) •It’s a type ! So it means :
  • 15. struct Date{ int month; int day; int year; } x,y ; struct PersonInfo { double height;//in cm int weight;//in kg Date birthday; }; Structures PersonInfo christoph ; christoph.height=170; christoph.weight=70; christoph.birthday.month=10 ; christoph.birthday.day=3 ; christoph.birthday.year=1978 ; •To reach to its members :
  • 16. struct Date{ int month; int day; int year; } x,y ; struct PersonInfo { double height;//in cm int weight;//in kg Date birthday; }; Structures PersonInfo christoph ; christoph.height=170; christoph.weight=70; christoph.birthday.month=10 ; christoph.birthday.day=3 ; christoph.birthday.year=1978 ; •To reach to its members :
  • 17. Structures •Initialize : struct Date{ int month; int day; int year; } x,y ; struct PersonInfo { double height;//in cm int weight;//in kg Date birthday; }; •Like Arrays
  • 18. Structures •Initialize : struct Date{ int month; int day; int year; } x,y ; struct PersonInfo { double height;//in cm int weight;//in kg Date birthday; }; •Like Arrays •Sequentially
  • 19. Structures •Initialize : struct Date{ int month; int day; int year; } x,y ; struct PersonInfo { double height;//in cm int weight;//in kg Date birthday; }; •Like Arrays •Sequentially •PersonInfo
  • 20. Structures •Initialize : struct Date{ int month; int day; int year; } x,y ; struct PersonInfo { double height;//in cm int weight;//in kg Date birthday; }; •Like Arrays •Sequentially •PersonInfo •height
  • 21. Structures •Initialize : struct Date{ int month; int day; int year; } x,y ; struct PersonInfo { double height;//in cm int weight;//in kg Date birthday; }; •Like Arrays •Sequentially •PersonInfo •height •weight
  • 22. Structures •Initialize : struct Date{ int month; int day; int year; } x,y ; struct PersonInfo { double height;//in cm int weight;//in kg Date birthday; }; •Like Arrays •Sequentially •PersonInfo •height •weight •birthday
  • 23. Structures •Initialize : struct Date{ int month; int day; int year; } x,y ; struct PersonInfo { double height;//in cm int weight;//in kg Date birthday; }; •Like Arrays •Sequentially •PersonInfo •height •weight •birthday •month •day •year
  • 24. Structures •Initialize : struct Date{ int month; int day; int year; } x,y ; struct PersonInfo { double height;//in cm int weight;//in kg Date birthday; }; •Like Arrays •Sequentially •PersonInfo •height •weight •birthday •month •day •year
  • 25. Structures •Initialize : struct Date{ int month; int day; int year; } x,y ; struct PersonInfo { double height;//in cm int weight;//in kg Date birthday; }; •Like Arrays •Sequentially •PersonInfo •height •weight •birthday •month •day •year
  • 26. Structures •Initialize : struct Date{ int month; int day; int year; } x,y ; struct PersonInfo { double height;//in cm int weight;//in kg Date birthday; }; •Like Arrays •Sequentially •PersonInfo •height •weight •birthday •month •day •year
  • 27. Structures •Initialize : struct Date{ int month; int day; int year; } x,y ; struct PersonInfo { double height;//in cm int weight;//in kg Date birthday; }; •Like Arrays •Sequentially •PersonInfo •height •weight •birthday •month •day •year
  • 28. Structures •Initialize : struct Date{ int month; int day; int year; } x,y ; struct PersonInfo { double height;//in cm int weight;//in kg Date birthday; }; PersonInfo christoph ={170,70, 10,3,1978};
  • 29. Structures •Initialize : struct Date{ int month; int day; int year; } x,y ; struct PersonInfo { double height;//in cm int weight;//in kg Date birthday; }; PersonInfo christoph ={170,70, 10,3,1978};
  • 30. Structures •Initialize : struct Date{ int month; int day; int year; } x,y ; struct PersonInfo { double height;//in cm int weight;//in kg Date birthday; }; PersonInfo christoph ={170,70, 10,3,1978};
  • 31. Structures •Initialize : struct Date{ int month; int day; int year; } x,y ; struct PersonInfo { double height;//in cm int weight;//in kg Date birthday; }; PersonInfo christoph ={170,70, 10,3,1978};
  • 32. Structures •Initialize : struct Date{ int month; int day; int year; } x,y ; struct PersonInfo { double height;//in cm int weight;//in kg Date birthday; }; PersonInfo christoph ={170,70, 10,3,1978};
  • 33. Structures •Initialize : struct Date{ int month; int day; int year; } x,y ; struct PersonInfo { double height;//in cm int weight;//in kg Date birthday; }; PersonInfo christoph ={170,70};
  • 34. Structures •Initialize : struct Date{ int month; int day; int year; } x,y ; struct PersonInfo { double height;//in cm int weight;//in kg Date birthday; }; PersonInfo christoph ={170,70}; month=0; day=0; year=0;
  • 35. Structures •Initialize : struct Date{ int month; int day; int year; } x,y ; struct PersonInfo { double height;//in cm int weight;//in kg Date birthday; }; PersonInfo christoph ={170,70}; month=0; day=0; year=0;
  • 36. Structures •Initialize : struct Date{ int month; int day; int year; } x,y ; struct PersonInfo { double height;//in cm int weight;//in kg Date birthday; }; Note : Unlike Array , when you initialize , if you pass the number of members ! You will have an Error !
  • 37.
  • 38. & To save the memebers values !
  • 41.
  • 42.
  • 43. Classes •It’s like a Struct. •Its members could be Functions and data • it supports( information hiding, data abstraction, and encapsulation )
  • 44. Classes •It’s like a Struct. •Its members could be Functions and data • it supports( information hiding, data abstraction, and encapsulation ) •private, only seen in the current class(for class functions) , unseen out of class ! • public, seen everywhere (in current class and out of class) •We use two things in classes :
  • 45. Classes •It’s like a Struct. •Its members could be Functions and data • it supports( information hiding, data abstraction, and encapsulation ) •Mostly in each class , you might have get(privateto variables )and set(variablesprivate) functions •private, only seen in the current class(for class functions) , unseen out of class ! • public, seen everywhere (in current class and out of class) •We use two things in classes :
  • 46. Classes •Mostly in each class , you might have get(privateto variables )and set(variablesprivate) functions
  • 47. Classes •Mostly in each class , you might have get(privateto variables )and set(variablesprivate) functions Accessor functions Mutator functions
  • 48. Classes class className{ private: ……….members …….. public: ……….members …….. } ;
  • 49. Classes class className{ private: ……….members …….. public: ……….members …….. } ; Don’t forget!
  • 50.
  • 51. •You can definitions them here ! •But it’s better not !
  • 52.
  • 53.
  • 54. Returned type Class name “ : : “
  • 55.
  • 57. Classes class className{ private: ……….members …….. public: ……….members …….. } ;
  • 58. Classes class className{ int num,den; public: ……….members …….. } ;
  • 59. Classes struct structName{ int num,den; …members …….. } ;
  • 60. Classes struct structName{ int num,den; …members …….. } ;
  • 61. That’s for today We’re finished !!
  • 62. 2 bytes team Group : group link Mobile phone- Kinan : 0994385748 Facebook account : kinan’s account 2 bytes team