Hello everybody!

I wrote the following classes:
OilStation:

class OilStation : public Date{
  protected:
      int code;
      char *Address;
      float Amount[K];
  public:
  ...
};

and Price:

class Price : public OilStation {
 public: 
     Price(){}
    void changeAmount();
   ...

};

In changeAmount function i try to change the elements that are stored in array Amount, but the protected array Amount of class OilStation isn't visible in the implementation file of class Price. Specifically, the error is: "error: Amount was not declared in this scope". I can't understand this, as class Price inherits class OilStation and protected members should be visible in public inheritance... Am i right? I also include the proper header files, so there is no such kind of a problem. Any idea would be appreciated... Thank you in advance for spending your time with me!

There's not much here to work with. It may be beneficial to post more of your code.

A few questions for you to think about/answer (in no particular order):

  1. How is "changeAmount()" defined?
  2. Is "K" a constant or a variable, and is it visible to both classes?
  3. Are you positive the headers are present?
  4. Are you using some sort of namespace?

There's not much here to work with. It may be beneficial to post more of your code.

A few questions for you to think about/answer (in no particular order):

  1. How is "changeAmount()" defined?
  2. Is "K" a constant or a variable, and is it visible to both classes?
  3. Are you positive the headers are present?
  4. Are you using some sort of namespace?

Thank you Fbody for your answer.. Well, i don't know what went wrong, but i just rewrited my code and now is just fine.. I guess that a detail that never observed caused a mess in my code.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.