#include <iostream>
#include<string>
using namespace std;
class Book
{
private:
string title;
double price;
public:
Book();
void setTitle(string s);
void setPrice(double p);
string getTitle() const
{return title;}
double getPrice() const
{return price;}
bool hasKeyword(string key);
};
Book::Book()
{
title="None";
price=0;
}
void Book :: setTitle(string s)
{
title=s;
}
void Book::setPrice(double p)
{
if(p>0)
{
price=p;
}
else
{
price=0;
}
}
void Initalize(Book *book, int size)
{
for(int i=0;i>size;i++)
{
string t[size];
double p[size];
cout<<"Enter the title: ";
cin>> t[i];
cout<<"Enter the price: $";
cin>>p[i];
}
}
const int SIZE=3;
int main()
{
int number;
string key;
Book book;
cout<< "Enter the number of books: ";
cin>> number;
book[SIZE]=new [number];
I have no idea. How can I make dynamically create in the main function?
Initalize(book,number);
cout<<"Enter the keyword: ";
cin>>key;
system ("pause");
return 0;
}
I want to make like the picture in the attachment.
However, I don't know how to make it. I am so stuck in class lesson.
Please help me.