By Недялко Ангелов


2018-04-16 13:02:33 8 Comments

Create three classes to be linked by inheritance. Base class Product that has three data elements - name, price, and weight of the Product. Then make derived Product class called Purchase containing data on the quantity of goods purchased and the weight of the goods.

EDIT: What I don't know is how/where to add the purchased goods.

This is what i got for now.

#include <iostream>
#include <string>
using namespace std;

class Product {
protected:
    string name;
    double price;
    double weight;

public:
    Product(string, double, double);
    string getName() {return name;}
    double getPrice() {return price;}
    double getWeight() {return weight;}
};
class Purchase : public Product {
private:
    Purchase(string n, double p, double w);

public:

};

class Verification : public Purchase {
private:

public:

};

 int main(){

    system("pause");
}

Product::Product(string n, double p, double w)
{
    name = n;
    price = p;
    weight = w;
}

0 comments

Related Questions

Sponsored Content

21 Answered Questions

[SOLVED] What is the "-->" operator in C++?

31 Answered Questions

1 Answered Questions

[SOLVED] The Definitive C++ Book Guide and List

  • 2008-12-23 05:23:56
  • grepsedawk
  • 1844648 View
  • 4254 Score
  • 1 Answer
  • Tags:   c++ c++-faq

7 Answered Questions

[SOLVED] Python class inherits object

10 Answered Questions

[SOLVED] How can I profile C++ code running in Linux?

  • 2008-12-17 20:29:24
  • Gabriel Isenberg
  • 401899 View
  • 1445 Score
  • 10 Answer
  • Tags:   c++ unix profiling

25 Answered Questions

[SOLVED] Why not inherit from List<T>?

33 Answered Questions

[SOLVED] Prefer composition over inheritance?

15 Answered Questions

[SOLVED] How do you declare an interface in C++?

16 Answered Questions

[SOLVED] Difference between private, public, and protected inheritance

Sponsored Content