/*Pass By Value
Display the title of book having
greater price
*/
#include<iostream>
using namespace std;
class Book
{
int price;
char title[20],author[20];
public:
void accept()
{
cout<<"\n\n Enter title, author and price of the book:";
cin>>title>>author>>price;
}
void display()
{
cout<<"\n\n Tittle: "<<title;
cout<<"\n Author: "<<author;
cout<<"\n Price: "<<price;
}
void max(Book b1,Book b2);
};
void Book::max(Book b1,Book b2)
{
if(b1.price>b2.price)
b1.display();
else if(b2.price>b1.price)
b2.display();
else
{
cout<<"\n\n Same Price: ";
b1.display();
b2.display();
}
}
int main()
{
Book b1,b2;
b1.accept();
b2.accept();
cou<<"\n Max Price:";
b1.max(b1,b2);
return 0;
}
Display the title of book having
greater price
*/
#include<iostream>
using namespace std;
class Book
{
int price;
char title[20],author[20];
public:
void accept()
{
cout<<"\n\n Enter title, author and price of the book:";
cin>>title>>author>>price;
}
void display()
{
cout<<"\n\n Tittle: "<<title;
cout<<"\n Author: "<<author;
cout<<"\n Price: "<<price;
}
void max(Book b1,Book b2);
};
void Book::max(Book b1,Book b2)
{
if(b1.price>b2.price)
b1.display();
else if(b2.price>b1.price)
b2.display();
else
{
cout<<"\n\n Same Price: ";
b1.display();
b2.display();
}
}
int main()
{
Book b1,b2;
b1.accept();
b2.accept();
cou<<"\n Max Price:";
b1.max(b1,b2);
return 0;
}