mirror of
https://github.com/szymon-jozef/ZUT-notatki.git
synced 2026-10-28 11:10:38 +01:00
prawie zrobione zadania
This commit is contained in:
22
uczelnia/2_semestr/programowanie/laby/lab10/zad7.cpp
Normal file
22
uczelnia/2_semestr/programowanie/laby/lab10/zad7.cpp
Normal file
@@ -0,0 +1,22 @@
|
||||
#include <iostream>
|
||||
|
||||
class Ksztalt {
|
||||
public:
|
||||
virtual double pole() const = 0;
|
||||
virtual ~Ksztalt() = default;
|
||||
};
|
||||
|
||||
class Kolo : public Ksztalt {
|
||||
double r;
|
||||
|
||||
public:
|
||||
Kolo(double promien) : r(promien) {}
|
||||
double pole() const { return 3.14 * r * r; }
|
||||
};
|
||||
|
||||
void wypisz(Ksztalt &k) { std::cout << k.pole(); }
|
||||
|
||||
int main() {
|
||||
Kolo k = Kolo(2);
|
||||
wypisz(k);
|
||||
}
|
||||
Reference in New Issue
Block a user