Stworzyć klase która ma dwa pola(Class Element string nazwa;float cena)utworzyc konstruktor domyślny, parametryczny, domniemany. stworzyć funkcję publiczną która pozwala ustalić cene.
trzeba zastosować coś z tym bool == dawałem juz podobne zadanie teraz podaje wam gotowy kod który się kompiluje. Nie hejtujcie jestem początkującym programistą
oto kod
#include <iostream> using namespace std; class Element { public: string nazwa; float cena; Element()//konstruktor domyslny { nazwa="pudlo"; cena=0; } Element(string n, float c)//konstruktor parametryczny { nazwa=n; cena=c; } void ustaw_cene() { cout<<"Nazwa elementu: "<<nazwa<<endl; float cena; cout<<"podaj cene "; cin>>cena; } bool operator==(const Element& temp) { if((nazwa == temp.nazwa) && (cena == temp.cena)) return true; return false; } }; int main() { Element e1; e1.ustaw_cene(); return 0; }