Ok so I am currently working on a program that uses a class to store integer arrays. I have most of the code done, but I am having trouble on the main.cpp part of my program. The program should display this:
OBJ 1:
2 3 4
OBJ 2:
1 4 -2
Addition:
OBJ 1 =
3 7 6
Subtraction:
OBJ 1 = 1 -1 6
But when I run and compile my program, this is what I get:
OBJ 1:
2 3 4
OBJ 2:
ADDING:
OBJ 1 =
4 6 8
Subtraction:
OBJ 1 =
I would greatly appreciate it if someone could help me with this. Here is my current main.cpp:
Code:
#include <iostream>
#include "SafeArray.h"
using namespace std;
int main()
{
// Declare a SafeArray object
Safe obj;
Safe obj2;
int x;
obj.set(2,0);
obj.set(3,1);
obj.set(4,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;
}