@RamilH/

TragicPleasedLinks

C++

No description

fork
loading
Files
  • main.cpp
  • arraydb.cpp
  • arraydb.hpp
  • makefile
  • outofbounds.hpp

This Plugin Crashed!

Error: Error: must not create an existing file {"type":"CREATE_FILE","wid":"0.3739665323210899","path":"main.cpp","file":{"path":"main.cpp","content":{"asEncoding":{"base64":"I2luY2x1ZGUgImFycmF5ZGIuY3BwIgojaW5jbHVkZSA8aW9zdHJlYW0+CnVzaW5nIG5hbWVzcGFjZSBzdGQ7CgojaWZuZGVmIF9fQVJJVEhBUlJfSFBQX18KI2lmbmRlZiBfX0xJTUFSUl9IUFBfXwoKdGVtcGxhdGUgPGNsYXNzIFR5cGU+CnZvaWQgZGlzcGxheSAoQXJyYXlEYjxUeXBlPiAmIGFyKQp7CiAgIGNvdXQgPDwgIkZ1bmMhXG4iOwogICBjb3V0IDw8IGFyOwogICBjb3V0IDw8ICJGdW5jIVxuIjsKfQoKaW50IG1haW4gKHZvaWQpCnsKCiAgQXJyYXlEYjxpbnQ+IHRlc3Q7CgogICB1bnNpZ25lZCBpbnQgcmVnaW9uczsKICAgY291dCA8PCAiRW50ZXIgbnVtYmVyIG9mIHJlZ2lvbnM6ICI7CiAgIGNpbiA+PiByZWdpb25zOwoKICAgLy8gQ3JlYXRlIGFuICJhcnJheSIgb2YgdGhhdCBzaXplCiAgIEFycmF5RGI8ZG91YmxlPiB0b25zKHJlZ2lvbnMpOwogIAogICBjb3V0IDw8ICJFbnRlciB0aGUgcmVnaW9uYWwgc2FsZXMgaW4gdG9uczpcbiI7CiAgIGludCBpOwogICBmb3IgKGkgPSAwOyBpIDwgcmVnaW9uczsgaSsrKQogICB7CiAgICAgIGNvdXQgPDwgIlJlZ2lvbiAiIDw8IChpKzEpIDw8ICI6ICAiOwogICAgICBjaW4gPj4gdG9uc1tpXTsKICAgICAgLy8gdG9ucy5vcGVyYXRvcltdKGkpCiAgIH0KICAgCiAgIGNvdXQgPDwgdG9uczsKICAgCiAgICAvLyBEZWZhdWx0IG9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IVxuIjsKICAgcmV0dXJuIDA7Cn0KI2VuZGlmCiNlbmRpZg=="},"asBuffer":null},"loaded":true}}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
#include "arraydb.cpp"
#include <iostream>
using namespace std;

#ifndef __ARITHARR_HPP__
#ifndef __LIMARR_HPP__

template <class Type>
void display (ArrayDb<Type> & ar)
{
   cout << "Func!\n";
   cout << ar;
   cout << "Func!\n";
}

int main (void)
{

  ArrayDb<int> test;

   unsigned int regions;
   cout << "Enter number of regions: ";
   cin >> regions;

   // Create an "array" of that size
   ArrayDb<double> tons(regions);
  
   cout << "Enter the regional sales in tons:\n";
   int i;
   for (i = 0; i < regions; i++)
   {
      cout << "Region " << (i+1) << ":  ";
      cin >> tons[i];
      // tons.operator[](i)
   }
   
   cout << tons;
   
    // Default object
   ArrayDb<double> dup;

   // Array assignment - calls the overloaded operator=
   dup = tons;
   cout << "Here's the original data:\n" << tons;
   cout << "Here's the copy :\n" << dup;

   // Pass the array without passing size
   display (dup);

   double wts[5] = {155.2, 189.6, 174.3, 256.9, 203.5};

   // Initialize an ArrayDb to an array
   ArrayDb<double> bod (wts,5);
   
   cout << "Here are the weights:\n" << bod;

   //try to exceed array limit
   cout << "Index: value \n";

  try
  {
    cout << "Testing Out of Bounds Error with ranges!" << endl;
    for (int i = -2; i < 4 ; i++ )
      cout << "In index " << i << " " << tons[-1] << endl;
  }

  catch (OutOfBounds& i)
  {     
      cout << "\nOut of bounds caught!" << endl;
      cout << i.what() << endl << endl;     
  }

    cout << "FINISHED!\n";
   return 0;
}
#endif
#endif