Main.cpp

Ok so I am currently trying to add and subtract two sets of integer arrays. When I run my program, the program does not subtract the numbers from the first set with the numbers from the second set. Could anyone here take a look at my code and help me figure out what the problem is?

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
#include <iostream>

#include "SafeArray.h"

using namespace std;



int main()

{
   // Declare a SafeArray object
    Safe obj;
    Safe obj2;
    int x;

    obj.set(5,0);
    obj.set(6,1);
    obj.set(7,2);
    
    obj2.set(4,0);
    obj2.set(3,1);
    obj2.set(2,2);
    
    
    cout << "OBJ 1: " << endl;
    obj.print();

    cout << "OBJ 2: " << endl;
    obj2.print();

    cout << "ADDING: " << endl;
    obj.add(obj2);

    cout << "OBJ 1 = " << endl;
    obj.print();

    cout << " Subtraction: " << endl;
    obj.subtract(obj2);

    cout << "OBJ 1 = " << endl;
    obj.print();
    


   return 0;

}
well we would have to see your subtract function in the SafeArray class
Topic archived. No new replies allowed.