int main() { Stonewt base(11, 0.0, Stonewt::STONE); std::cout << base; Stonewt one(12, 17, Stonewt::dPOUND); std::cout << one; Stonewt two(12, 13, Stonewt::dPOUND); std::cout << two; one.compare(two); Stonewt tab[6]; //tablica obiektów for (int i = 0; i < 3; i++) tab[i].init(i); //inicjalizacja trzech pierwszych obiektów wartoœciami 1, 2, 3 for (int i = 0; i < 6; i++) std::cout << tab[i]; std::cout << "Inicjalizuj kolejne wartosci:\n"; for (int i = 3; i < 6; i++) { std::cout << i + 1 << ": "; tab[i].input(i); } for (int i = 0; i < 6; i++) std::cout << i + 1 << ": " << tab[i]; //poszukiwanie maximum const Stonewt * ptr = tab; for (int i = 0; i < 6; i++) ptr = &ptr->maximum(tab[i]); std::cout << "maximum: " << *ptr; disp_counter(tab, base, 6); //poszukiwanie minimum for (int i = 0; i < 6; i++) ptr = &ptr->minimum(tab[i]); std::cout << "minimum: " << *ptr; //minimum innym sposobem Stonewt tmp; tmp = min(tab, 6); std::cout << "friend min: " << tmp; //inicjalizacja vactora tablicy obiektów std::vector<Stonewt> Vec; Vec.emplace_back(99, 0.0, Stonewt::STONE); Vec.emplace_back(89, 1.1, Stonewt::STONE); Vec.push_back(Stonewt(87, 2.2, Stonewt::STONE)); //metoda push_back Vec.emplace_back(9.0, 2.8, Stonewt::iPOUND); Vec.emplace_back(9, 2.8, Stonewt::dPOUND); std::cout << Vec; return 0; }
Stonewt Stonewt::operator*(double a) const { return Stonewt(pounds * a); }
Stonewt Stonewt::operator-(const Stonewt & st) const { return Stonewt(pounds - st.pounds); }