SlideShare a Scribd company logo
1 of 1
Tutorial 5
Classes and Objects
Self Review Questions
1. What are classes? How does it help in data hiding?
2. How structures in c are different from structures in C++?
3. What do you mean by visibility labels?
4. Differentiate between
a. Classes and Structures
b. Class and Object
c. Member Function and Non Member Function
d. Member function and Friend function
5. How memory is allocated to Objects and static data members?
6. Give an example to illustrate the use array of objects.
7. Illustrate the use of scope resolution operator as class scope operator.
Programming Questions
1. Write a class to represent a vector (a series of float values). Include member functions
to perform the following tasks:
(a) To create the vector
(b) To modify the value of a given element
(c) To multiply by a scalar value
(d) To display the vector in the form (10, 20, 30.....)
Write a program to test your class.
2. Create two classes DM and DB which store the value of distances. DM stores distances in
metres and centimetres and DB in feet and inches. Write a program that can read values
for the class objects and add one object of DM with another object of DB.
Use a friend function to carry out the addition operation. The object that stores the results
may be a DM object or DB object, depending on the units in which the results are
required. The display should be in the format of feet and inches or metres and centimetres
depending on the object on display.

More Related Content

Viewers also liked

Dr. Russell A. Barkley - Dedicated to Education and Research on ADHD
Dr. Russell A. Barkley - Dedicated to Education and Research on ADHDDr. Russell A. Barkley - Dedicated to Education and Research on ADHD
Dr. Russell A. Barkley - Dedicated to Education and Research on ADHDjollymedal7131
 
인천휴게텔≪다솜넷≫수원오피≪수유건마,천안오피방
인천휴게텔≪다솜넷≫수원오피≪수유건마,천안오피방인천휴게텔≪다솜넷≫수원오피≪수유건마,천안오피방
인천휴게텔≪다솜넷≫수원오피≪수유건마,천안오피방dasom49
 
Plantilla doris y monik modificada
Plantilla doris y monik modificadaPlantilla doris y monik modificada
Plantilla doris y monik modificadalina vanessa nunez
 

Viewers also liked (8)

Walking Crew Poster(1)
Walking Crew Poster(1)Walking Crew Poster(1)
Walking Crew Poster(1)
 
Dr. Russell A. Barkley - Dedicated to Education and Research on ADHD
Dr. Russell A. Barkley - Dedicated to Education and Research on ADHDDr. Russell A. Barkley - Dedicated to Education and Research on ADHD
Dr. Russell A. Barkley - Dedicated to Education and Research on ADHD
 
Current RESUME
Current RESUMECurrent RESUME
Current RESUME
 
Die schiesstrainerin folder-web
Die schiesstrainerin folder-webDie schiesstrainerin folder-web
Die schiesstrainerin folder-web
 
Health is Wealth
Health is WealthHealth is Wealth
Health is Wealth
 
인천휴게텔≪다솜넷≫수원오피≪수유건마,천안오피방
인천휴게텔≪다솜넷≫수원오피≪수유건마,천안오피방인천휴게텔≪다솜넷≫수원오피≪수유건마,천안오피방
인천휴게텔≪다솜넷≫수원오피≪수유건마,천안오피방
 
Plantilla doris y monik modificada
Plantilla doris y monik modificadaPlantilla doris y monik modificada
Plantilla doris y monik modificada
 
Letter
LetterLetter
Letter
 

Similar to Tutorial 5 classes 1

cprogramming questions for practice end term
cprogramming questions for practice end termcprogramming questions for practice end term
cprogramming questions for practice end termSheelendra3
 
OOM MCQ 2018
OOM  MCQ 2018OOM  MCQ 2018
OOM MCQ 2018lochan100
 
Oop suplemnertary september 2019
Oop suplemnertary september  2019Oop suplemnertary september  2019
Oop suplemnertary september 2019ktuonlinenotes
 
S2 DATA PROCESSING FIRST TERM C.A 2
S2 DATA PROCESSING FIRST TERM C.A 2S2 DATA PROCESSING FIRST TERM C.A 2
S2 DATA PROCESSING FIRST TERM C.A 2Ejiro Ndifereke
 
Mit4021–%20 c# and .net
Mit4021–%20 c# and .netMit4021–%20 c# and .net
Mit4021–%20 c# and .netsmumbahelp
 
Oop r&s may 2019 (2)
Oop r&s may 2019 (2)Oop r&s may 2019 (2)
Oop r&s may 2019 (2)ktuonlinenotes
 
C++ programming introduction
C++ programming introductionC++ programming introduction
C++ programming introductionsandeep54552
 
COMP111-Week-1_138439.pptx
COMP111-Week-1_138439.pptxCOMP111-Week-1_138439.pptx
COMP111-Week-1_138439.pptxFarooqTariq8
 
Bca winter 2013 2nd sem
Bca winter 2013 2nd semBca winter 2013 2nd sem
Bca winter 2013 2nd semsmumbahelp
 
oop lecture 3
oop lecture 3oop lecture 3
oop lecture 3Atif Khan
 
CS8592 Object Oriented Analysis & Design - UNIT II
CS8592 Object Oriented Analysis & Design - UNIT IICS8592 Object Oriented Analysis & Design - UNIT II
CS8592 Object Oriented Analysis & Design - UNIT IIpkaviya
 
2009 Punjab Technical University B.C.A Object Oriented Proagramming Language ...
2009 Punjab Technical University B.C.A Object Oriented Proagramming Language ...2009 Punjab Technical University B.C.A Object Oriented Proagramming Language ...
2009 Punjab Technical University B.C.A Object Oriented Proagramming Language ...Monica Sabharwal
 
Object Oriented Design
Object Oriented DesignObject Oriented Design
Object Oriented DesignAravinth NSP
 

Similar to Tutorial 5 classes 1 (20)

Ooad quiz
Ooad quizOoad quiz
Ooad quiz
 
cprogramming questions for practice end term
cprogramming questions for practice end termcprogramming questions for practice end term
cprogramming questions for practice end term
 
Oops 2018
Oops 2018Oops 2018
Oops 2018
 
OOM MCQ 2018
OOM  MCQ 2018OOM  MCQ 2018
OOM MCQ 2018
 
Oop suplemnertary september 2019
Oop suplemnertary september  2019Oop suplemnertary september  2019
Oop suplemnertary september 2019
 
S2 DATA PROCESSING FIRST TERM C.A 2
S2 DATA PROCESSING FIRST TERM C.A 2S2 DATA PROCESSING FIRST TERM C.A 2
S2 DATA PROCESSING FIRST TERM C.A 2
 
C++ Unit_01
C++ Unit_01C++ Unit_01
C++ Unit_01
 
Oop r&s may 2019
Oop r&s may 2019Oop r&s may 2019
Oop r&s may 2019
 
Mit4021–%20 c# and .net
Mit4021–%20 c# and .netMit4021–%20 c# and .net
Mit4021–%20 c# and .net
 
Oop r&s may 2019 (2)
Oop r&s may 2019 (2)Oop r&s may 2019 (2)
Oop r&s may 2019 (2)
 
C++ programming introduction
C++ programming introductionC++ programming introduction
C++ programming introduction
 
COMP111-Week-1_138439.pptx
COMP111-Week-1_138439.pptxCOMP111-Week-1_138439.pptx
COMP111-Week-1_138439.pptx
 
Bca winter 2013 2nd sem
Bca winter 2013 2nd semBca winter 2013 2nd sem
Bca winter 2013 2nd sem
 
oop lecture 3
oop lecture 3oop lecture 3
oop lecture 3
 
CS8592 Object Oriented Analysis & Design - UNIT II
CS8592 Object Oriented Analysis & Design - UNIT IICS8592 Object Oriented Analysis & Design - UNIT II
CS8592 Object Oriented Analysis & Design - UNIT II
 
Class diagram
Class diagramClass diagram
Class diagram
 
2009 Punjab Technical University B.C.A Object Oriented Proagramming Language ...
2009 Punjab Technical University B.C.A Object Oriented Proagramming Language ...2009 Punjab Technical University B.C.A Object Oriented Proagramming Language ...
2009 Punjab Technical University B.C.A Object Oriented Proagramming Language ...
 
Unit 5.ppt
Unit 5.pptUnit 5.ppt
Unit 5.ppt
 
Object Oriented Design
Object Oriented DesignObject Oriented Design
Object Oriented Design
 
Object Oriented Design
Object Oriented DesignObject Oriented Design
Object Oriented Design
 

Recently uploaded

SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )Tsuyoshi Horigome
 
IMPLICATIONS OF THE ABOVE HOLISTIC UNDERSTANDING OF HARMONY ON PROFESSIONAL E...
IMPLICATIONS OF THE ABOVE HOLISTIC UNDERSTANDING OF HARMONY ON PROFESSIONAL E...IMPLICATIONS OF THE ABOVE HOLISTIC UNDERSTANDING OF HARMONY ON PROFESSIONAL E...
IMPLICATIONS OF THE ABOVE HOLISTIC UNDERSTANDING OF HARMONY ON PROFESSIONAL E...RajaP95
 
High Profile Call Girls Nashik Megha 7001305949 Independent Escort Service Na...
High Profile Call Girls Nashik Megha 7001305949 Independent Escort Service Na...High Profile Call Girls Nashik Megha 7001305949 Independent Escort Service Na...
High Profile Call Girls Nashik Megha 7001305949 Independent Escort Service Na...Call Girls in Nagpur High Profile
 
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube ExchangerStudy on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube ExchangerAnamika Sarkar
 
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
 
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
 
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
 
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur EscortsCall Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur High Profile
 
Introduction to Multiple Access Protocol.pptx
Introduction to Multiple Access Protocol.pptxIntroduction to Multiple Access Protocol.pptx
Introduction to Multiple Access Protocol.pptxupamatechverse
 
(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Service
(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Service(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Service
(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Serviceranjana rawat
 
Analog to Digital and Digital to Analog Converter
Analog to Digital and Digital to Analog ConverterAnalog to Digital and Digital to Analog Converter
Analog to Digital and Digital to Analog ConverterAbhinavSharma374939
 
Introduction to IEEE STANDARDS and its different types.pptx
Introduction to IEEE STANDARDS and its different types.pptxIntroduction to IEEE STANDARDS and its different types.pptx
Introduction to IEEE STANDARDS and its different types.pptxupamatechverse
 
Porous Ceramics seminar and technical writing
Porous Ceramics seminar and technical writingPorous Ceramics seminar and technical writing
Porous Ceramics seminar and technical writingrakeshbaidya232001
 
Coefficient of Thermal Expansion and their Importance.pptx
Coefficient of Thermal Expansion and their Importance.pptxCoefficient of Thermal Expansion and their Importance.pptx
Coefficient of Thermal Expansion and their Importance.pptxAsutosh Ranjan
 
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...Dr.Costas Sachpazis
 
Software Development Life Cycle By Team Orange (Dept. of Pharmacy)
Software Development Life Cycle By  Team Orange (Dept. of Pharmacy)Software Development Life Cycle By  Team Orange (Dept. of Pharmacy)
Software Development Life Cycle By Team Orange (Dept. of Pharmacy)Suman Mia
 
HARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IVHARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IVRajaP95
 
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur High Profile
 
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
 

Recently uploaded (20)

SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )
 
IMPLICATIONS OF THE ABOVE HOLISTIC UNDERSTANDING OF HARMONY ON PROFESSIONAL E...
IMPLICATIONS OF THE ABOVE HOLISTIC UNDERSTANDING OF HARMONY ON PROFESSIONAL E...IMPLICATIONS OF THE ABOVE HOLISTIC UNDERSTANDING OF HARMONY ON PROFESSIONAL E...
IMPLICATIONS OF THE ABOVE HOLISTIC UNDERSTANDING OF HARMONY ON PROFESSIONAL E...
 
High Profile Call Girls Nashik Megha 7001305949 Independent Escort Service Na...
High Profile Call Girls Nashik Megha 7001305949 Independent Escort Service Na...High Profile Call Girls Nashik Megha 7001305949 Independent Escort Service Na...
High Profile Call Girls Nashik Megha 7001305949 Independent Escort Service Na...
 
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube ExchangerStudy on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
 
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
 
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
 
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
 
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur EscortsCall Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
 
Introduction to Multiple Access Protocol.pptx
Introduction to Multiple Access Protocol.pptxIntroduction to Multiple Access Protocol.pptx
Introduction to Multiple Access Protocol.pptx
 
(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Service
(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Service(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Service
(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Service
 
Analog to Digital and Digital to Analog Converter
Analog to Digital and Digital to Analog ConverterAnalog to Digital and Digital to Analog Converter
Analog to Digital and Digital to Analog Converter
 
Introduction to IEEE STANDARDS and its different types.pptx
Introduction to IEEE STANDARDS and its different types.pptxIntroduction to IEEE STANDARDS and its different types.pptx
Introduction to IEEE STANDARDS and its different types.pptx
 
Porous Ceramics seminar and technical writing
Porous Ceramics seminar and technical writingPorous Ceramics seminar and technical writing
Porous Ceramics seminar and technical writing
 
Coefficient of Thermal Expansion and their Importance.pptx
Coefficient of Thermal Expansion and their Importance.pptxCoefficient of Thermal Expansion and their Importance.pptx
Coefficient of Thermal Expansion and their Importance.pptx
 
★ CALL US 9953330565 ( HOT Young Call Girls In Badarpur delhi NCR
★ CALL US 9953330565 ( HOT Young Call Girls In Badarpur delhi NCR★ CALL US 9953330565 ( HOT Young Call Girls In Badarpur delhi NCR
★ CALL US 9953330565 ( HOT Young Call Girls In Badarpur delhi NCR
 
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
 
Software Development Life Cycle By Team Orange (Dept. of Pharmacy)
Software Development Life Cycle By  Team Orange (Dept. of Pharmacy)Software Development Life Cycle By  Team Orange (Dept. of Pharmacy)
Software Development Life Cycle By Team Orange (Dept. of Pharmacy)
 
HARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IVHARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IV
 
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
 
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
 

Tutorial 5 classes 1

  • 1. Tutorial 5 Classes and Objects Self Review Questions 1. What are classes? How does it help in data hiding? 2. How structures in c are different from structures in C++? 3. What do you mean by visibility labels? 4. Differentiate between a. Classes and Structures b. Class and Object c. Member Function and Non Member Function d. Member function and Friend function 5. How memory is allocated to Objects and static data members? 6. Give an example to illustrate the use array of objects. 7. Illustrate the use of scope resolution operator as class scope operator. Programming Questions 1. Write a class to represent a vector (a series of float values). Include member functions to perform the following tasks: (a) To create the vector (b) To modify the value of a given element (c) To multiply by a scalar value (d) To display the vector in the form (10, 20, 30.....) Write a program to test your class. 2. Create two classes DM and DB which store the value of distances. DM stores distances in metres and centimetres and DB in feet and inches. Write a program that can read values for the class objects and add one object of DM with another object of DB. Use a friend function to carry out the addition operation. The object that stores the results may be a DM object or DB object, depending on the units in which the results are required. The display should be in the format of feet and inches or metres and centimetres depending on the object on display.