Advertisement
Guest User

Untitled

a guest
Jun 22nd, 2017
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.64 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5.  
  6. class Shape{
  7. protected:
  8. int width;
  9. int height;
  10. public:
  11.  
  12. virtual void postavi(){
  13. cout << "senad" << endl;
  14. }
  15.  
  16.  
  17. };
  18. class Rectangle: public Shape {
  19. public:
  20. Rectangle (int a, int b) {
  21. width = a;
  22. height = b;
  23. }
  24. void postavi() {
  25. cout << width * height << endl;
  26. }
  27.  
  28. };
  29.  
  30. class Triangle: public Shape {
  31. public:
  32. Triangle (int a, int b) {
  33. width = a;
  34. height = b;
  35. }
  36. void postavi() {
  37. cout << (width * height) / 2 << endl;
  38. }
  39. };
  40.  
  41. int main() {
  42. Rectangle A(5, 10);
  43. Triangle B(10, 5);
  44. A.postavi();
  45. B.postavi();
  46.  
  47.  
  48.  
  49.  
  50. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement