Hi,
I had a base class and two derived classes. I don't know how to set the constructor of the 3rd class in order to inherit the base class and 2nd class data members - name, price and life.
I tried many but incurred many errors.
Any help?
Thanks a lot.
gogo
#ifndef PRODUCT_H
#define PRODUCT_H
#include <iostream>
#include <string>
using namespace std;
//--------Base Class--------------//
class Product
{
private:
string manufacturer;
char flag;
string date;
protected:
double price;
string name;
int life;
public:
Product();
Product(string na);
Product(string na, double pr);
Product(string na, double pr, int li);
virtual void display()=0;
};
//----------------- 1st level derived class----------------//
class Fruitublic Product
{
private:
string demand;
string supply;
double percent;
public:
Fruit(){}
Fruit(string na, double pr, int li):Product(na, pr, li){}
Fruit(string na, double pr, int li, string de, string su):Product(na, pr, li), demand(de), supply(su){}
double calpercent(string de, string su);
double pricechange();
void display();
};
//-------------------- 3rd level derived class----------------//
class Orangeublic Fruit
{
public:
Orange(){} // ?? How should I set it here for the inheritance of the base class and 2nd class data members?
Orange(string de, double su){}
double calpercent(string de, string su);
double pricechange();
void display();
}
#endif
;