#include <iostream>
#include <string>
using namespace std;
class Product {
protected:
string name;
double price;
string EAN;
public:
Product(string n, double p, string e) {
name = n;
price = p;
EAN = e;
}
void ShowProductInfo() {
cout << "name: " << name << endl;
cout << "price: $ " << price << endl;
cout << "EAN: " << EAN << endl;
}
};
class AmazonProduct : public Product {
private:
string ASIN;
public:
AmazonProduct(string n, double p, string e, string a)
: Product(n, p, e) {
ASIN = a;
}
void ShowProductInfo() {
Product::ShowProductInfo();
cout << "ASIN: " << ASIN << endl;
}
};
int main()
{
Product product("EE toothpaste", 1.99, "123abc");
product.ShowProductInfo();
cout << endl;
AmazonProduct aProduct("EE toothpaste", 1.99, "123abc", "cs21fe");
aProduct.ShowProductInfo();
cout << endl;
return 0;
}
To embed this project on your website, copy the following code and paste it into your website's HTML: