Guest User

Untitled

a guest
Feb 26th, 2019
118
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.02 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4. class Array{
  5. public:
  6.  
  7.     int* tab;
  8.     const int size_of_tab;
  9.  
  10.     Array(int size_tab);
  11.     ~Array();
  12.  
  13.     int get(int index){
  14.         if((index>size_of_tab)||(index<0)) cout<<"Niepoprawny numer indexu!"<<endl;
  15.         else return tab[index];
  16.     }
  17.  
  18.     void set(int index, int newValue){
  19.     tab[index]=newValue;
  20.     }
  21.  
  22.     int* front(){
  23.         return tab;
  24.     }
  25.     int* back(){
  26.         return &tab[size_of_tab];
  27.     }
  28.     int size(){
  29.         return size_of_tab;
  30.     }
  31.     void fill(int value)
  32.     {
  33.         for(int i=0; i<size_of_tab;i++){
  34.             tab[i]=value;
  35.         }
  36.     }
  37.     void assign(const int tab_source[], int tabSize){
  38.         if(tabSize>size_of_tab) tabSize=size_of_tab;
  39.         for(int i=0; i<tabSize; i++){
  40.                 tab[i]=tab_source[i];
  41.         }
  42.  
  43.     }
  44. };
  45.  
  46. Array::Array(int size_tab=20): size_of_tab(size_tab){
  47. tab=new int(size_tab);
  48. }
  49. Array::~Array(){
  50. delete [] tab;
  51. }
  52.  
  53.  
  54.  
  55. int main()
  56. {
  57.  
  58. return 0;
  59. }
Advertisement
Add Comment
Please, Sign In to add comment