0

It just wont acces private fields

.hpp:
private:
    std::string model;

public:
    Piekarnik &operator << (const Ciasto &ciasto);
    friend std::ostream &operator<<(std::ostream &os, const Ciasto &ciasto);


.cpp:
Piekarnik &Piekarnik::operator<<(const Ciasto &ciasto)
{
    append(ciasto);
    return *this;
}
ostream &operator<<(ostream &os, const Piekarnik &piekarnik) // dwuargumentowy;
{
      os<<"Piekarnik (model: "<<piekarnik.model<<", temperatura: " << piekarnik.obecnyProgram.temperatura <<", pieczenie: " << EnumToString(piekarnik.obecnyProgram.pieczenie) << ", wlozone ciasto: " << EnumToString(piekarnik.wlozoneCiasto.rodzaj);
      return os<<")";
}

error: 'std::string Piekarnik::model' is private

foxale
  • 127
  • 9
  • Check your declaration and definition signature, it's not matched. Here is the declared `friend std::ostream &operator<<(std::ostream &os, const Ciasto &ciasto);` – Danh Dec 16 '15 at 00:22

1 Answers1

0

Change your friend declaration to

friend std::ostream &operator<<(std::ostream &os, const Piekarnik&);
Danh
  • 5,916
  • 7
  • 30
  • 45