0

How would i incorporate inheritance into this c++ progam

001 #include <iostream> 002 #include<fstream> 003 #include<stdlib.h> 004 #include <cstring> 005 #include <conio.h> 006 #include "Insurance.h" 007 #include "Date.h" 008 #include "Client.h" 009 #include "MotorVehicle.h" 010 #include "Life.h" 011 #include "Home.h" 012 013 using std:: string; 014 using std:: cout; 015 using std:: cin; 016 using std::ios; 017 using std::ofstream; 018 using std::ifstream; 019 using std::cerr; 020 021 void randomCreate(); 022 void randomWrite(Insurance & , int ); 023 void randomRead(); 024 void randomUpdate(); 025 026 027 028 int main() 029 { system("color 2F"); 030 031 int position = 0; 032 int choice = 0; 033 MotorVehicle MV; 034 Home H; 035 Life L; 036 Insurance In; 037 Client C; 038 039 040 041 cout<<".:::::SELECT MENU OPTION:::::.\n\n"; 042 cout<<"\n1. Add A Insurance Policy."; 043 cout<<"\n2. Delete A Insurance Policy."; 044 cout<<"\n3. Edit A Insurance Policy."; 045 cout<<"\n4. Veiw Policy Details."; 046 cout<<"\n5. Exit The Programme."; 047 048 cout<<"\n\nSELECT#"; 049 cin>>choice; 050 051 052 switch(choice){ 053 case 1: 054 system("cls"); 055 randomCreate(); 056 In.Display(); 057 system("cls"); 058 cout<<".:::::PLEASE SELECT INSURANCE TYPE:::::.\n"; 059 cout<<"\n\n1. Home Insurance."; 060 cout<<"\n2. Life Insurance."; 061 cout<<"\n3. Motor Vehicle Insurance."; 062 cout<<"\n0. Exit To Main Menu."; 063 cout<<"\n\nSELECT#"; 064 065 cin>>choice; 066 067 068 switch(choice) 069 { 070 case 1: 071 system("cls"); 07

29th Nov 2017, 4:45 PM
Trever Young
Trever Young - avatar
21 Answers
+ 2
I use inheritance a bunch. Here are a couple I've done on here https://code.sololearn.com/cS65hz5hszfv/?ref=app https://code.sololearn.com/ckukgISgLYaw/?ref=app
29th Nov 2017, 6:57 PM
Zeke Williams
Zeke Williams - avatar
+ 1
Oh OK. I see. I really appreciate the help up given. No idea of who might be able to have sample code i could follow?
29th Nov 2017, 5:59 PM
Trever Young
Trever Young - avatar
+ 1
Thank you. appreciate the help
29th Nov 2017, 6:09 PM
Trever Young
Trever Young - avatar
0
OK thanks.
29th Nov 2017, 4:52 PM
Trever Young
Trever Young - avatar
0
How do I link it?
29th Nov 2017, 4:57 PM
Trever Young
Trever Young - avatar
0
I am using the web
29th Nov 2017, 4:59 PM
Trever Young
Trever Young - avatar
29th Nov 2017, 5:06 PM
Trever Young
Trever Young - avatar
0
like that?
29th Nov 2017, 5:06 PM
Trever Young
Trever Young - avatar
29th Nov 2017, 5:15 PM
Trever Young
Trever Young - avatar
0
that one.
29th Nov 2017, 5:15 PM
Trever Young
Trever Young - avatar
0
i am being introduced to objects classes and inheritance and not quite sure how to go about modifying my existing program to incorporate those new concepts.
29th Nov 2017, 5:20 PM
Trever Young
Trever Young - avatar
0
Use Insurance as your super class. Add subclasses for home, life, and vehicle. Inherent common things like bill payment. Have subclass only things like make & model for vehicle.
29th Nov 2017, 5:51 PM
John Wells
John Wells - avatar
0
OK. Can I see some similar code so I can go about doing the modification? An example. I want to to the coding so I get the implementation of it.
29th Nov 2017, 5:54 PM
Trever Young
Trever Young - avatar
- 1
I suggest putting code in playground file and linking it here.
29th Nov 2017, 4:47 PM
John Wells
John Wells - avatar
- 1
Are you using web or app?
29th Nov 2017, 4:59 PM
John Wells
John Wells - avatar
- 1
Copy web address when looking at code view. Paste it as reply text.
29th Nov 2017, 5:02 PM
John Wells
John Wells - avatar
- 1
No, you didn't get the link to your code. This one? https://code.sololearn.com/c0wUsMjT8Bp6/?ref=app
29th Nov 2017, 5:08 PM
John Wells
John Wells - avatar
- 1
Open your source file so you can see the code and copy that link.
29th Nov 2017, 5:12 PM
John Wells
John Wells - avatar
- 1
Perfect
29th Nov 2017, 5:15 PM
John Wells
John Wells - avatar
- 1
I don't have anything in C++ using that only Java. I have programmed in C++ for decades so I only used it to get working algorithms to convert to Java, when I wasn't comfortable with my Java programming.
29th Nov 2017, 5:57 PM
John Wells
John Wells - avatar