Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- class Shape{
- protected:
- int width;
- int height;
- public:
- virtual void postavi(){
- cout << "senad" << endl;
- }
- };
- class Rectangle: public Shape {
- public:
- Rectangle (int a, int b) {
- width = a;
- height = b;
- }
- void postavi() {
- cout << width * height << endl;
- }
- };
- class Triangle: public Shape {
- public:
- Triangle (int a, int b) {
- width = a;
- height = b;
- }
- void postavi() {
- cout << (width * height) / 2 << endl;
- }
- };
- int main() {
- Rectangle A(5, 10);
- Triangle B(10, 5);
- A.postavi();
- B.postavi();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement