#pragma once #include "iostream" #include "conio.h" #include "fstream" class product { private: char* Name; double Kkal; double Belok; double Yglevod; double Gur; public: product() { Kkal = Belok = Yglevod = Gur = 0; Name= ""; } product(double bel, double ygl, double gur, char* name) { Belok= bel; Yglevod= ygl; Gur= gur; Kkal= (bel*4)+(ygl*4)+(gur*9); Name= name; } friend std::ostream& operator<<(std::ostream& os,const product p1) { os<<p1.Name<<p1.Belok<<" белка, "<<p1.Gur<<" жира, "<<p1.Yglevod<<" углеводов, "<<p1.Kkal<<"ккал "; return os; } friend std::ofstream& operator<<(std::ofstream& fout, const product& p1) { fout.open("product.txt",std::ios::app); fout << p1.Name <<std::endl; fout << p1.Belok << ' ' << p1.Gur << ' ' << p1.Yglevod << ' ' << p1.Kkal<< std::endl; return fout; } friend std::ifstream& operator>>(std::ifstream& fin, product& p1) { fin.getline(p1.Name, 30); fin >> p1.Belok; fin >> p1.Gur; fin >> p1.Yglevod; (fin >> p1.Kkal).get(); return fin; } product operator+(const product& a) const { product summa; summa.Belok= Belok+a.Belok; summa.Gur= Gur+a.Gur; summa.Yglevod= Yglevod+a.Yglevod; summa.Kkal= Kkal+a.Kkal; return summa; } }; friend std::ifstream& operator>>(std::ifstream& fin, product& p1) does not work correctly