Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- class Kalkulator
- {
- protected:
- float liczba1;
- float liczba2;
- public:
- float dodaj_liczby();
- Kalkulator();
- Kalkulator(float nliczba1, float nliczba2);
- };
- class SuperKal : public Kalkulator
- {
- public:
- SuperKal() {}
- SuperKal(float nx, float ny);
- float Superoper();
- };
- float Kalkulator::dodaj_liczby()
- {
- return liczba1+liczba2;
- }
- Kalkulator::Kalkulator()
- {
- liczba1=0.0;
- liczba2=0.0;
- }
- Kalkulator::Kalkulator(float nliczba1, float nliczba2)
- {
- liczba1=nliczba1;
- liczba2=nliczba2;
- }
- SuperKal::SuperKal(float nx, float ny) : Kalkulator(nx, ny){
- }
- float SuperKal::Superoper()
- {
- return liczba1*liczba2;
- }
- int main()
- {
- Kalkulator k1(5.4,8.2);
- cout << k1.dodaj_liczby() << endl;
- SuperKal SK1(5.5,7.7);
- cout << SK1.Superoper() << endl;
- cout << SK1.dodaj_liczby() << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement