Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- class Author{
- string mail, name; char gender;
- public:
- void getDetails(){
- cout<< "Author name: ";
- cin>>name;
- cout<< "Author email: ";
- cin>>mail;
- cout<< "Author gender: ";
- cin>>gender;
- }
- };
- class Book{
- string bookName, isbn; float price; Author *authors;
- public:
- void getDetails(){
- int n;
- cout<< "Text book name: ";
- cin>>bookName;
- cout<< "How many authors: ";
- cin>>n;
- for(int i=0; i<n; i++){
- authors[i].getDetails();
- }
- cout<< "Price(BDT): ";
- cin>>price;
- cout<< "ISBN no";
- cin>>isbn;
- }
- };
- class Course{
- string courseId, courseTitle; int noOfCredits; Book textbook;
- public:
- void getDetails(){
- cout<< "Enter course ID: ";
- cin>>courseId;
- cout<< "Enter course title: ";
- cin>>courseTitle;
- cout<< "Enter no of credits: ";
- cin>>noOfCredits;
- cout<< "Enter textbook detail...";
- textbook.getDetails();
- }
- //friend int operator+=(int , Course );
- };
- /*int operator+=(int &n, Course c){
- n+=c.noOfCredits;
- return n;
- }*/
- int main()
- {
- Course *courseArr; int n, i;
- cout<<"How many courses? "; cin>>n;
- allocateAndPopulateCourses(courseArr, n);
- for(i=0;i<n;i++)cout<<courseArr[i]<<endl;
- //int totalCredits = 0;
- //for(i=0;i<n;i++) totalCredits += courseArr[i];
- //cout<<"Total no of credits of these courses is: "<<totalCredits<<endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement