dimanche 22 février 2015

Call parent constructor with private members in parent class


It is possible to call the parent constructor having the members of it in private? I know that with protected this works, but I prefer to use private, is there any way to solve this?



class Product {

std::string id;
std::string description;
double rateIVA;

public:
Product(std::string id, std::string description, double rateIVA);
~Product();

// Abstract Methods / Pure Virtual Methods
virtual double getIVAValue() = 0;
virtual double getSaleValue() = 0;

// Virtual Method
virtual void print() const;

// Setters & Getters
void setId(std::string id);
std::string getId() const;
void setDescription(std::string description);
std::string getDescription() const;
void setRateIVA(double rateIVA);


double getRateIVA() const;
};

// Parent Class
class FixedPriceProduct : protected Product {

double price;

public:
FixedPriceProduct();
FixedPriceProduct(double price); // Implement here
~FixedPriceProduct();

double getIVAValue();
double getSaleValue();

virtual void print() const;
};



Aucun commentaire:

Enregistrer un commentaire