#include <iostream>
using std::cout;
using std::endl;
class Book
{
public:
void show_book(void) {
cout << title << ": " << price << endl;
}
Book(char *title, float price);
private:
char title[256];
float price;
};
Book::Book(char *title, float price)
{
strcpy(Book::title, title);
Book::price = price;
}
int main()
{
Book *Arr[3];
Arr[0] = new Book("The C++ Programming Language, 4th Edition", 37.48);
Arr[1] = new Book("The Ultimate Crash Course to Learning C++", 9.95);
Arr[2] = new Book("C++17 By Example", 44.99);
for (int i = 0; i < 3; i++)
Arr[i]->show_book();
for (int i = 0; i < 3; i++)
delete Arr[i];
return 0;
}
/*
run:
The C++ Programming Language, 4th Edition: 37.48
The Ultimate Crash Course to Learning C++: 9.95
C++17 By Example: 44.99
*/