Open navigation menu
Close suggestions
Search
Search
en
Change Language
Upload
Sign in
Sign in
Download free for days
0 ratings
0% found this document useful (0 votes)
132 views
22 pages
Oop Practical 13 To 15
Uploaded by
shailesh Prajapati
AI-enhanced title
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content,
claim it here
.
Available Formats
Download as PDF or read online on Scribd
Download
Save
Save Oop Practical 13 to 15 For Later
Share
0%
0% found this document useful, undefined
0%
, undefined
Print
Embed
Report
0 ratings
0% found this document useful (0 votes)
132 views
22 pages
Oop Practical 13 To 15
Uploaded by
shailesh Prajapati
AI-enhanced title
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content,
claim it here
.
Available Formats
Download as PDF or read online on Scribd
Carousel Previous
Carousel Next
Download
Save
Save Oop Practical 13 to 15 For Later
Share
0%
0% found this document useful, undefined
0%
, undefined
Print
Embed
Report
Download
Save Oop Practical 13 to 15 For Later
You are on page 1
/ 22
Search
Fullscreen
Object Oriented Programming Using C ++ (22316) eb IV VI vi 13: Program to Implement Concept Multiple Inheritance Practical Practical Significance: i Multiple Inheritances is a feature of C++ where a class can inherit from more than one classes. Relevant Program Outcomes (POs) © Basic knowledge: Apply knowledge of basic mathematics, sciences and basic engineering to solve the broad-based Computer engineering problem. © Discipline knowledge: Apply Computer engineering discipline - specific knowledge to solve core computer engincering related problems. © Experiments and practice: Plan to perform experiments and practices to use the results to solve broad-based Computer engineering problems. o Engineering tools: Apply relevant Computer technologies and tools with an understanding of the limitations. © Communication: Communicate effectively in oral and written form. Competency and Practical skills This practical is expected to develop the following skills in you Develop C+ programs to solve broad-based problems 1, Apply multiple inheritances to real life problems. 2. Compile the program. 3. Debug and execute the program. Relevant Course Outcome(s) Implement Inheritance in C++ program Practical Outcome (POs) Write/ Compile/ debug / Execute simple C++ program using multiple inheritance. Relevant Affective domain related Outcome(s) 1. Select proper programming environment in C++. 2. Follow safety measures 3. Follow ethical practices. Minimum Theoretical Background 1, Inheritance :-It is the process of inheriting properties of objects of one class by objects of another class. The class which inherits the properties of another class is called Derived or Child or Sub class and The class whose properties are inherited is called Base or Parent or Super class. 2. Multiple Inheritance :-When a class is derived from two or more base classes, such inheritance is called Multiple Inheritance. It allow us to combine the features of several existing classes into a single class. Maharashira state Board of Technical Education @Object Oriented Programming Using C ++ (22316) IX Precautions 1. Handle computer system and peripherals with care. 2. Follow safety practices X Resources used S.No] Name of Resource Specification 1 [Computer System : RAM> Dy) with broad specifications | "S Ith Gen .8aB, 5I2GR Rae. 2 Software Tusboctr 3 | Any other resource used XI Result (Output of the Program) oe : -PIQQra-m-. ee BBE CU EEA A ET. 4 USING, Paiva Cece rote ate XII__ Practical Related Questions Note: Below given are few sample questions for reference. Teacher must design ‘more such questions so as to ensure the achievement of identified CO. (Note: Use Point VIII to X and XIII to XV for all relevant programming exercise use blank pages provided or attach more pages if needed.) 1. What is the difference between multiple and multilevel inheritance in C++? 2. State output of the following code: #include
#include
class liquid ( float specific gravity: public: void input () ( cout<<"Specific gravity: "; cin>>specific gravity; ) void output () ( cout<<"Specific gravity <
>rate; ) void output () ( cout<<"Rate(per liter): §"<
class Base ( public: virtual void print() const = 1 class Derivedone : ‘ public Base public: void print() const ‘ cout << "Derivedone\n"; } M class DerivedTwo : public Base { public: void print () const { cout << “DerivedTwo\n"; ) ip class Multiple : Derivedtwo { public DerivedOne, public public: void print() const ‘ DerivedTwo print(); , int main() int i; Multiple both; DerivedOne one; Derivedtwo two: Base *array[ 3 J+ array{ 0] = éboth; array{ 1 ] = Gone; array[ 2] = &two; array[ i] -> print(); return 0; Evror:- Base’ v5 an ambigious base of HO ultip le So it produces an exsor & This Progam "Sof Visual clags,|Object Oriented Programming Using © ++ 22316) b) Vinelude
: struct a Output*- { Ant county ‘ : Inherited struct b | ints value, ye struct @ + public a, public b i Me int main() ( ct p= new povalue = "0; Sout << "Inherited"; return 07 (Space for answers)LN eee oman ett inctuidle
Class Are pubic aloes tho void meCraa es Hoat b) Cout
>? length >> breadthy= ‘he ineiucle
_ class Cricketer me —__——_—|_-4 - Char cname £207; 2 } mt ec sores a | “ce cname, | Couts<’ \n_ cricketer’s Score i” <<Void getre— = Cout<<’’ \n Enter bow less name and no: of — “Maichets tencena’)) ee ______ Cin» bo_ nome >> Uoickets; Gout <2 "ND Bocoler’s Names!’ << b-mame 5 ___Coute<™\ No- OF wickets taken i” << Wickets + cout
> br mame >> auns: — an pe ~ yey fas eens | = — ——s _ | a id_disptiayaQ a __ cout*\n_Batsmoan name:"<< btname; a cout \q So -of buns Made’! << wuns } —'Object Oriented Programming Using © ++ 22016) m Iv vi vil Maharashtra state Board of Technical Education Practical No. 14: Program to Implement Pointer to Object Practical Significance; ‘The pointer to objects helps to improve the efficiency of the program and access the objects dynamically. Relevant Program Outcomes (POs) ic knowledge: Apply knowledge of basic mathematics, sciences and basic ‘engineering to solve the broad-based Computer engineering problem. ‘© Discipline knowledge: Apply Computer engineering discipline ~ specific knowledge to solve core computer engineering related problems o Experiments and practice: Plan to perform experiments and practices to use the results to solve broad-based Computer engineering problems © Engineering tools: Apply relevant Computer technologies and tools with an understanding of the limitations © Communication: Communicate eff tively in oral and written form. Competency and Practical skills This practical is expected to develop the following skills in you Develop C+ programs to solve broad-based problems 1. Define real life problems using pointer to objects, 2.Compile the program, 3. Debug and execute the program, Relevant Course Outcome(s) Implement Inheritance in C+ program Use Polymorphism in C++ program, Practical Outcome (POs) Write/ Compile/ debug / Execute simple C++ program using pointer to object Relevant Affective domain related Outcome(s) 1. Select proper programming environment in C++ 2. Follow safety measures 3. Follow ethical practices. Minimum Theoretical Background Pointers to objects: C+ allows you to have pointers to objects. The pointers pointing to objects are referred to as Object Pointers. ‘Syntax:- class-name * object-pointer ; where class-name is the name of an alread! is the pointer to an object of this class type. For example, to declare optr as an object pointer of Sampl shall write Sample *optr ;where Sample is already defined be es we When accessing members of a class using an object poi (C>) is used instead of dot operator, ect pointer, the arrow operator ly defined class and object-pointerObject Oriented Programming Using C++ (22316) VIII Resources required Sr. | Ni if Nel |” Rasoarse Specification Quantity Remarks 1 | Hardware: Computer (13-15 | Computer preferable), RAM System minimum 2 GB and onwards, HDD 40GB and — 40GB and’ | As per batch For all | _ size Experiments 2 | Operating ‘Windows /LINUX system 3 | Software Turbo C+ Version 3.0 or any | other IX ___ Precautions 1. Handle computer system and peripherals with care. 2. Follow safety practices. X Resources used S.No. | Name of Resource Specification T | Computer System : with broad 15, 84B RAM | windovas 4 specifications - 2__| Software Turbo ctt 3 | Any other resource used XI__Result (Output of the Program) We... SUcessfully. pointer...10.... Object: PIOGTarn...Using XII Practical Related Questions Note: Below given are few sample questions for reference. Teacher must design more such questions so as to ensure the achievement of identified CO. (Note: Use Point VIII to X and XIII to XV for all relevant programming exercise use blank pages provided or attach more pages if needed.) 1. State output of the following code: #include
#include
glass myciass int 4; public: void read(int 3) ( cH int getint() ( return i; ‘Maharashtra state Board of Technical Education aObject Oriented Programming Using C ++ (22316) } void main() ( elrser(); myclass ob, *objectPointer; objectPointer = sob; objectPointer->read(10); cout<
getint (); getch(); ) 2. Which is the pointer which denotes the object calling the member function? a) Variable pointer b) This pointer c) Null pointer 4) Zero pointer 3. A pointer can be initialized with . a) null b) zero ©) Address of an object of same type 4) All of them (Space for answers) Re TINS. PORNO. A @MALE. SG. th @....OBjECK.. SA mg... Calling.....the...... ne mbea.... function. Fra stale Board of Technical EducationXIII Exercise: Attempt Q1 or Q2 or Q3 and Q.4.a or b from the following: (Note: Use Point VIII to X and XIII to XV for all relevant programming exercise use blank pages provided or attach more pages if needed.) A” Write a C++ program to declare a class “Book” containing data members book_name, auther_name, and price .Accept this information for one object of the class using pointer to that object. 2 Write a C++ program to declare a class “Box” having data members height, width and breadth. Accept this information for one object using pointer to that object -Display the area and volume of that object. 3. Write a C++ program to declare a class birthday having data members day, month, year. Accept this information for five objects using pointer to the array of objects. Maharashtra state Board of Technical Education 38is Programming Using C++ (22316) 4, Complete the given table: Write & justify Program Code Gakial a) Output: Hinclude
a #include
nitializg class Tine dato members short int hh, mm, ss: using object ery, with value ( hh = mm = ss = 0; egciie G ) oo void getdata(int i, int J, int k) | PBINEING net member mn = 3; using object ss =k: time (2,234) void prndata (void) ( prmtmg coutcer\ntine 1s "eenhce"s ereesscc"\n"s | Wag mew ds using point void main() a i is time - elrser(); Time T1, *tptr; 16:00; 00 cout<<"Initializing data members using the object, with values 12, 22, 11\n"; T1.getdata (12, 22,11); cout<<"Printing members using the object T1.prndata(); tptr = 6Tl; cout<<"Printing members using the object pointer "; tptr->prndata(); cout<<"\nInitializing data members using the object poiny4r, with values 15, 10, 16\n"; ta(15, 10, 16)7 jting members using the object T1.prndata (); cout<<"Priqting members using the object pointer ";|tptr->prndata(); getch(); ) Maharashtra state Board of Technical Education =Object Oriented Programming Using C++ (22316) b) Finclude
#include
using namespace std; class student ay " Convert Chat private: . int_rolino; 2) deciavation string name; public: student () :r0l1no (0) ,name ("") Suntay error a student (int x, string a): erroy roLino (#) ;name.(n) pares oy expecte void get () ie ( ‘get’: coutccventer roll now; | 4) 9 is, cin>>rolino; cout<<"enter name"; not Member , cin>>name of student void print () Hl 5)unabie to cout<<"roll no is *<
Qut.norne >> prices —— ———_____— Ni outs<“*\n Bo ateeb name <<" \n Author _ oe << out yore <<*\0_ price?” ¢¢ prices. Void yoind: : a ere RS Ps &by = P—> getO : P> Put, Be getcho;s ao ae ae q coeeeObject Oriented Programming Using C++ (22316) Iv VI vo Practical No. 15: Program to Implement Pointer Derived Class Practical Significance: The key feature of class inheritance is that a pointer to a derived class is type- compatible with a pointer to its base class. Relevant Program Outcomes (POs) © Basic knowledge: Apply knowledge of basic mathematics, sciences and basic engineering to solve the broad-based Computer engineering problem. © Discipline knowledge: Apply Computer engineering discipline - specific knowledge to solve core computer engineering related problems. © Experiments and practice: Plan to perform experiments and practices to use the results to solve broad-based Computer engineering problems. © Engineering tools: Apply relevant Computer technologies and tools with an understanding of the limitations. © Communication: Communicate effectively in oral and written form. Competency and Practical skills ‘This practical is expected to develop the following skills in you Develop C++ programs to solve broad-based problems 1. Define pointer to derived class. 2. Compile the program. 3. Debug and execute the program. Relevant Course Outcome(s) Implement Inheritance in C++ program, Use Polymorphism in C++ program. Practical Outcome (POs) Write/ Compile/ debug / Execute simple C++ program using pointers to derived class. Relevant Affective domain related Outcome(s) 1. Select proper programming environment in C++. 2. Follow safety measures 3. Follow ethical practices. Minimum Theoretical Background Pointers to derived class 1, C++ allows base class pointers to point to derived class objects. 2. Let we have ~ class base { ... }; class derived : public base { ... }; ‘Then we can write — base *p]; derived Maharashtra state Board of Technical EducationDijecs Oriewies Programming Vising C# FEIN ne 4 hy, pl ~ 1A hy base *yl~ new derived; 3. Using a base class pointer (pointing tw « derived cass dbjed) we cam aocees only thove members of the derived chject that were inherited from the base Ih is different from the behavior that Lava shows, b. We can get Javalike behavior using virtual functions, 4. This is because the base pointer has knowledge only of the tase class 5. Itknows nothing abot the members added by the derived class (Sr Name a | Remarks |[No._| Resource | Specification | Quantity [ 1 | | Computer (3-15 | Computer | preferable), RAM | | System | minimum 2 GB and | | | onwards, HDD Band It woe | As perbatch | Windows LINUX | | | | Turbo C74 Version 3.0 oF any | ones 1 1. Handle computer system and peripherals with care. 2. Follow safety practices. ‘Specification 13, 8@B RAM, Win dovoslO Turbo c++ Maharashtra vate Board oh Technical Eawcation 100au Ga a_i ee) ~~ Object Oriented Programming Using C++ (22316) XII__ Practical Related Questions Note: Below given are few sample questions for reference. Teacher must design more such questions so as to ensure the achievement of identified CO. (Note: Use Point VIII to X and XIII to XV for all relevant programming exercise use blank pages provided or attach more pages if needed.) 1. State output of the following code: #include
class base ( public: void show() cout << “base\n”; ) class derived : public base ( public: void show() ( cout << “derived\n"; ) Me void main() ( base bl: bl.show() derived di; al. show(); base “pb — ébl; pb->show () pb = dl; pb->show () ) 2. A pointer to the base class can hold address of A) only base class object B) only derived class object C) base class object as well as derived class object. D) None of the above 3. Which variable stores the memory address of another variable? A)Reference _B) Pointer ©) Array D) None of the above (Space for answers) eonen A AA.¥ .F. IASS... OBj.0ch....OS.... RUS. vo TMC. MASS... OBOCL: Pointey.”..Work. ORIG... SHOES. th, an B. POLMEE. on the... Maharashtra state Board of Technical EducationObject Oriented Programming Using C++ 22316) 2._Complete the given table: Write & justify Program Code Output #include
class base output :- public: int nl; pointey void show() ( ‘ : of base cout<<"\nnl = “<
66 { cout<<*\nnl = “<
show() ; derive d cout<<”\n bptresd; pptr->nl=66; bptr->show () 7 return 0; ) by) Finclude
: class BaseClass ( output int x7 : public! Base object void setx(int 4) ( x10 ) Base. object int getx() ( return x; x1 4q ) x M Devived class DerivedClass ; public BaseClass ( Object xs 4q. int yi public: void sety(int i) ( yo is ‘Maharashtra state Board of Technical Education 10sOdject Oriented Programming Using C ++ (22316) , int gety() { return y? derivedobject: Pp = sbaseobject; po>setx(10)7 cout << "Base object x: " << p->getx() << Nee P = Sderivedobject: po>setx (33) 7 derivedobject .sety (88); cout << "Derived object x: * << p->getx() << ‘\ate ‘cout << "Derived object y: * << derivedObject.gety() << "\n's return 07 }~ Cout<< \n bo "Ze b3 O98 ckgetch 0d}
You might also like
Bca 304
PDF
No ratings yet
Bca 304
280 pages
Charotar University of Science & Technology & Devang Patel Institute of Advance Technology & Reserch CE144 Object Oriented Programming With C++
PDF
No ratings yet
Charotar University of Science & Technology & Devang Patel Institute of Advance Technology & Reserch CE144 Object Oriented Programming With C++
123 pages
Object Oriented Programming Lab File
PDF
No ratings yet
Object Oriented Programming Lab File
32 pages
MCA-108 Object Oriented Programming Using C++ L-T-P: 3-1-0
PDF
No ratings yet
MCA-108 Object Oriented Programming Using C++ L-T-P: 3-1-0
91 pages
OOP Theory 1 To 4
PDF
No ratings yet
OOP Theory 1 To 4
22 pages
18CS202J Object Oriented Design and Programming: Unit - 1
PDF
No ratings yet
18CS202J Object Oriented Design and Programming: Unit - 1
103 pages
Computer Engineering Object-Oriented Programming Using C++
PDF
83% (6)
Computer Engineering Object-Oriented Programming Using C++
16 pages
Computer Science C++ (083) Assignment Booklet Class Xii Academic Session: 2016-17
PDF
No ratings yet
Computer Science C++ (083) Assignment Booklet Class Xii Academic Session: 2016-17
49 pages
Summer Internship MOOC's CSE-443: Object Oriented Programming Using C++
PDF
No ratings yet
Summer Internship MOOC's CSE-443: Object Oriented Programming Using C++
17 pages
Botnari
PDF
No ratings yet
Botnari
12 pages
134 16SCCCS2 2020052107140659 PDF
PDF
No ratings yet
134 16SCCCS2 2020052107140659 PDF
94 pages
REVISED OOPM Lab Expt 1 To 11
PDF
No ratings yet
REVISED OOPM Lab Expt 1 To 11
29 pages
Object Oriented Programming Using C++
PDF
No ratings yet
Object Oriented Programming Using C++
169 pages
Inheritance: Junaed Sattar October 22, 2008
PDF
No ratings yet
Inheritance: Junaed Sattar October 22, 2008
27 pages
Msbte w22 22316
PDF
100% (4)
Msbte w22 22316
27 pages
DCO-312 Practical File10
PDF
No ratings yet
DCO-312 Practical File10
9 pages
Object Oriented Programming C++ Solved Manual
PDF
No ratings yet
Object Oriented Programming C++ Solved Manual
161 pages
Syllabus
PDF
No ratings yet
Syllabus
7 pages
Unit 4
PDF
No ratings yet
Unit 4
96 pages
OOP Practical 15
PDF
100% (1)
OOP Practical 15
7 pages
Object Oriented Programming Using C++
PDF
No ratings yet
Object Oriented Programming Using C++
5 pages
OOPS in C++ PDF
PDF
No ratings yet
OOPS in C++ PDF
7 pages
Paper 16: Computer Programming (C++ Theory) : SCAA Dated: 09.05.2019
PDF
No ratings yet
Paper 16: Computer Programming (C++ Theory) : SCAA Dated: 09.05.2019
2 pages
Oops Manual Answers
PDF
No ratings yet
Oops Manual Answers
21 pages
OOP P1 (270 - Varun Behere)
PDF
No ratings yet
OOP P1 (270 - Varun Behere)
8 pages
22316
PDF
No ratings yet
22316
7 pages
Practical File Oops
PDF
No ratings yet
Practical File Oops
41 pages
OOP Ques
PDF
No ratings yet
OOP Ques
10 pages
CSL0203 - OOP-Paradigm With C
PDF
No ratings yet
CSL0203 - OOP-Paradigm With C
5 pages
C++ Lab Manual Final
PDF
100% (1)
C++ Lab Manual Final
35 pages
University of Central Punjab: Faculty of Information Technology
PDF
No ratings yet
University of Central Punjab: Faculty of Information Technology
6 pages
Unit 3
PDF
No ratings yet
Unit 3
78 pages
Object Oriented Programming in C++
PDF
No ratings yet
Object Oriented Programming in C++
4 pages
C++ Practical Program
PDF
No ratings yet
C++ Practical Program
44 pages
Model Answer Paper Summer 2019
PDF
No ratings yet
Model Answer Paper Summer 2019
24 pages
Bca 3
PDF
No ratings yet
Bca 3
35 pages
Ita3001 Object-Oriented-programming Eth 1.0 37 Ita3001
PDF
No ratings yet
Ita3001 Object-Oriented-programming Eth 1.0 37 Ita3001
3 pages
C++ Ques
PDF
No ratings yet
C++ Ques
2 pages
OOP 16 Week Plan
PDF
No ratings yet
OOP 16 Week Plan
7 pages
C++ 5 Year
PDF
No ratings yet
C++ 5 Year
15 pages
Computer Programming Paradigm
PDF
No ratings yet
Computer Programming Paradigm
47 pages
Cpp-Brief
PDF
No ratings yet
Cpp-Brief
30 pages
24CS101
PDF
No ratings yet
24CS101
5 pages
Oop Sy
PDF
No ratings yet
Oop Sy
7 pages
APznzaYLsRd8Svkd4QP9GWRBjHWl6JF3tP-DIYCGU7pFD1X6qtAsz7ZX2kQOnid64S7jS975QD-L3XYk3YHaX6yh1fleocZkfr_LBd4bz90MlkJYyWn0n6Pl0YDIRgXKoH-xTdDz_mOXiqy_w72yPfSqcur8RAReuxRPEWSd059J9EaSwx0aY9hUllNjWsY5MwrUpt0qybtFmjwI-kbNsr
PDF
No ratings yet
APznzaYLsRd8Svkd4QP9GWRBjHWl6JF3tP-DIYCGU7pFD1X6qtAsz7ZX2kQOnid64S7jS975QD-L3XYk3YHaX6yh1fleocZkfr_LBd4bz90MlkJYyWn0n6Pl0YDIRgXKoH-xTdDz_mOXiqy_w72yPfSqcur8RAReuxRPEWSd059J9EaSwx0aY9hUllNjWsY5MwrUpt0qybtFmjwI-kbNsr
4 pages
Oops Labmanual - 2
PDF
No ratings yet
Oops Labmanual - 2
74 pages
OOPS
PDF
No ratings yet
OOPS
6 pages
313304-Object Oriented Programming Using c++-1
PDF
No ratings yet
313304-Object Oriented Programming Using c++-1
8 pages
Inheritance
PDF
No ratings yet
Inheritance
17 pages
Lab 11
PDF
No ratings yet
Lab 11
12 pages
BBA CA SEM IV Course Contents in Layout F Corrected 2-12-2022
PDF
No ratings yet
BBA CA SEM IV Course Contents in Layout F Corrected 2-12-2022
36 pages
Savitribai Phule Pune Universityoopsyllabus
PDF
No ratings yet
Savitribai Phule Pune Universityoopsyllabus
4 pages
C++ Notes
PDF
No ratings yet
C++ Notes
58 pages
Oops in CPP Comp Engg
PDF
No ratings yet
Oops in CPP Comp Engg
3 pages
22PLC25D - Introduction To C++ Programming
PDF
No ratings yet
22PLC25D - Introduction To C++ Programming
5 pages
Integrated BSC Cs 2nd Sem
PDF
No ratings yet
Integrated BSC Cs 2nd Sem
52 pages
C++ Oops Shortcut
PDF
No ratings yet
C++ Oops Shortcut
6 pages