Advertisement
Guest User

Untitled

a guest
Oct 21st, 2018
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.59 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. class Author{
  6. string mail, name; char gender;
  7. public:
  8. void getDetails(){
  9. cout<< "Author name: ";
  10. cin>>name;
  11. cout<< "Author email: ";
  12. cin>>mail;
  13. cout<< "Author gender: ";
  14. cin>>gender;
  15. }
  16. };
  17. class Book{
  18. string bookName, isbn; float price; Author *authors;
  19. public:
  20. void getDetails(){
  21. int n;
  22. cout<< "Text book name: ";
  23. cin>>bookName;
  24. cout<< "How many authors: ";
  25. cin>>n;
  26. for(int i=0; i<n; i++){
  27. authors[i].getDetails();
  28. }
  29. cout<< "Price(BDT): ";
  30. cin>>price;
  31. cout<< "ISBN no";
  32. cin>>isbn;
  33. }
  34. };
  35. class Course{
  36. string courseId, courseTitle; int noOfCredits; Book textbook;
  37. public:
  38. void getDetails(){
  39. cout<< "Enter course ID: ";
  40. cin>>courseId;
  41. cout<< "Enter course title: ";
  42. cin>>courseTitle;
  43. cout<< "Enter no of credits: ";
  44. cin>>noOfCredits;
  45. cout<< "Enter textbook detail...";
  46. textbook.getDetails();
  47. }
  48. //friend int operator+=(int , Course );
  49. };
  50. /*int operator+=(int &n, Course c){
  51. n+=c.noOfCredits;
  52. return n;
  53. }*/
  54. int main()
  55. {
  56. Course *courseArr; int n, i;
  57. cout<<"How many courses? "; cin>>n;
  58. allocateAndPopulateCourses(courseArr, n);
  59. for(i=0;i<n;i++)cout<<courseArr[i]<<endl;
  60. //int totalCredits = 0;
  61. //for(i=0;i<n;i++) totalCredits += courseArr[i];
  62. //cout<<"Total no of credits of these courses is: "<<totalCredits<<endl;
  63. return 0;
  64. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement