When i try and create a parameterized constructor for my Vegetable class, I get this error: not a non static data member or base class of class. The error occurs in the Vegetable.cpp file where the constructor is implemented.
Grocery.hpp
#include "Grocery.hpp"
class Grocery{
public:
Grocery();
Grocery(std::string name, double price, double weight);
bool operator==(const Grocery &rhs) const; // Comparison operator overload
protected:
std::string name_;
int quantity_;
double unit_price_;
double unit_weight_;
double total_price_;}; // end Grocery
#include "Grocery.cpp"
#endif
Vegetable.hpp
#ifndef Vegetable_
#define Vegetable_
#include "Grocery.hpp"
#include <string>
class Vegetable : public Grocery{
public:
Vegetable(std:: string,double price, double weight );
virtual void updateCost() override;
}
Vegetable.Cpp
#include <iostream>
#include <string>
#include "Vegetable.hpp"
Vegetable ::Vegetable(std :: string name, double price, double weight):name_(name),
unit_price_(price), unit_weight_(weight){
}
Error:
"name_" is not a nonstatic data member or base class of class "Vegetable"
"unit_price_" is not a nonstatic data member or base class of class "Vegetable"
"unit_weight_" is not a nonstatic data member or base class of class "Vegetable"
Why is it saying that name_, unit_price_, and unit_weight_ are not members of my vegetable class? didn't i inherit them, and they're protected in the vegetable class?