thezxtreme

Untitled

Jun 4th, 2020
38
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <iostream>
  2.  
  3. class Matrice
  4. {
  5. protected:
  6. int matrix[100][100];
  7.  
  8. public:
  9. virtual void set_Value(int row, int column, int value) = 0;
  10. virtual int get_Value(int row, int column) = 0;
  11. };
  12.  
  13. class Sparse : public Matrice
  14. {
  15. public:
  16. void set_Value(int row, int column, int value) override
  17. {
  18. matrix[row][column] = value;
  19. }
  20.  
  21. int get_Value(int row, int column) override
  22. {
  23. return matrix[row][column];
  24. }
  25. };
  26.  
  27. class Dense : public Matrice
  28. {
  29. public:
  30. void set_Value(int row, int column, int value) override
  31. {
  32. matrix[row][column] = value + 1;
  33. }
  34.  
  35. int get_Value(int row, int column) override
  36. {
  37. return matrix[row][column];
  38. }
  39. };
  40.  
  41.  
  42.  
  43. int main()
  44. {
  45. Sparse s1 = {};
  46. s1.set_Value(0, 0, 1337);
  47. std::cout << s1.get_Value(0, 0) << std::endl;
  48.  
  49. Dense d1 = {};
  50. d1.set_Value(0, 0, 1337);
  51. std::cout << d1.get_Value(0, 0) << std::endl;
  52.  
  53. return 0;
  54. }
RAW Paste Data

Adblocker detected! Please consider disabling it...

We've detected AdBlock Plus or some other adblocking software preventing Pastebin.com from fully loading.

We don't have any obnoxious sound, or popup ads, we actively block these annoying types of ads!

Please add Pastebin.com to your ad blocker whitelist or disable your adblocking software.

×