Question: Using Visual Studio 1. // This and the following 5 lines will go to the main program, main_prog.cpp 2. // Additional include statements should be

Using Visual Studio

Using Visual Studio 1. // This and the following 5 lines will

go to the main program, main_prog.cpp 2. // Additional include statements should

be added 3. // P91.cpp - This program is a driver written

to demonstrate how we can use a 4. // class inside another

one. 5. #include 6. using namespace std; 7. 8. // This part

will go to ID.h file 9. class ID 10. { 11. public:

1. // This and the following 5 lines will go to the main program, main_prog.cpp 2. // Additional include statements should be added 3. // P91.cpp - This program is a driver written to demonstrate how we can use a 4. // class inside another one. 5. #include 6. using namespace std; 7. 8. // This part will go to ID.h file 9. class ID 10. { 11. public: 12. IDO; 13. ID(int, int, int); 14. void display(); 15. private: 16. int left; 17. int middle; 18. int right; 19. }; 20. 21. // This part will go to Loan.h file 22. class Loan // Loan class definition 23. { 24. public: 25. Loan(); 26. Loan (ID id, float amount, float rate, int term); 27. void set(); 28. float payment); 29. void display(); private: 31. ID id; // assume an unique integer in three integer parts 32. float amount; // $ amount of the loan 33. float rate; // annual interest rate 34. int term; // number of months, length of the loan 35. }; 36. 37. // This part will go to the main program, main_prog.cpp 30. 38. int main() 39. { 40. Loan loan1(ID(111, 22,4444), 2300, 5.5, 48); // initialize to values given 41. Loan loan2; 42. 43. cout > 1; 93 cout > ; 95. cout >r; 97. 98 id = ID(1, 1, 1); 99. 180. cout > amount; 192. 103. cout > rate; 195. 106. cout > term; 188.) 189. 110. void Loan::display() 111. { 112. id.display(); 113. cout 5. 6. class ID 7. { 8. public: 9. ID(); 10. ID(int, int, int); 11. void display(); 12. private: 13. int left; 14. int middle; 15. int right; 16. }; 17. 18. tlendif // 3 What we do is test to see whether the IDH has been visited, or defined. If the .h file has not been defined (#ifndef ID_H), the definition following this statement is used to define the class (#define). If it has been defined, everything between the #ifndef ID_H and #endif is skipped. The format is the same for all other .h files, for example: In the Loan.h file 1. #ifndef Loan_H //1 2. Ildefine Loan_H //2 3. 4. 5. Wiendif / 3 // Write the above program in five different files as described by the comments at the top of each section. Once you have created the 5 files, include the ID.h and Loan.h file in the main. Make the changes in the other .h files so they will be visited twice. Once you have made all these changes, compile and link all parts to be sure that is working

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!