Advertisement
Guest User

Untitled

a guest
Dec 5th, 2016
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.96 KB | None | 0 0
  1. // 5-12-2016.cpp : Defines the entry point for the console application.
  2. //
  3.  
  4. #include "stdafx.h"
  5. #include <iostream>
  6. using namespace std;
  7.  
  8. class Obdlznik
  9. {
  10. protected: int a,b;
  11. public: Obdlznik();
  12. Obdlznik(int a, int b);
  13. int obsah();
  14. //void kresli();
  15. };
  16.  
  17. Obdlznik::Obdlznik()
  18. {
  19. a = 0;
  20. b = 0;
  21. }
  22.  
  23. Obdlznik::Obdlznik(int a, int b)
  24. {
  25. this->a=a;
  26. this->b=b;
  27. }
  28.  
  29. int Obdlznik::obsah() {
  30. int vypocet;
  31. vypocet = a * b;
  32. return vypocet;
  33. }
  34.  
  35.  
  36. class Stvorec : public Obdlznik {
  37. public: Stvorec();
  38. Stvorec(int a);
  39. int obsah();
  40. //void kresli();
  41. };
  42.  
  43. Stvorec::Stvorec() {
  44. a = 0;
  45. b = 0;
  46. }
  47.  
  48. Stvorec::Stvorec(int a) : Obdlznik(a,a){
  49. cout << "Ciselko: " << a << endl;
  50. }
  51.  
  52. int Stvorec::obsah() {
  53. return a*a;
  54. }
  55.  
  56.  
  57.  
  58. int _tmain(int argc, _TCHAR* argv[])
  59. {
  60. Obdlznik o(2,5);
  61. cout << "Obsah je: " << o.obsah() << endl;
  62. Stvorec s(2);
  63. cout << "Obsah stvorca je: " << s.obsah() << endl;
  64. getchar();
  65. getchar();
  66. return 0;
  67. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement