Files not linking properly

I should have just started with the files broken up and gone from there, but I thought it would save time to just write them all in one file. I built, compiled, linked, and successfully executed the program. Then I went to separate the info into separate files to be handed in. I created a new project, added blank header file for declarations, and 2 implementation files (1 for the class info - 1 for driver menu). None of the information has changed, but when I go to compile, it breaks.

What have I missed?

My Header:
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
78
79
80
81
82
83
84
85
86
87
88
89
90
//                      PROJECT FILES
//       LIST ALL PROGRAM AND HEADER FILES IN THE PROJECT
// 
// VectorClass.h
// Vector.cpp
//=============================================================================
// 		PROCESS THIS FILE ONLY PER PROJECT
// allows for additional
#ifndef VectorClass2_H					
#define VectorClass2_H
//=============================================================================
//             INCLUDE FILES
#include <iostream>
//
//=============================================================================
//             CONSTANT DEFINITION
// none
//=============================================================================
//		EXTERNAL CLASS VARIABLE					
// none
//=============================================================================
//             FUNCTION PROTOTYPES
// none
//=============================================================================
//              Class Object
//
class Vector {
//=============================================================================
public:
	Vector();
	Vector(double x, double y, double z);
	Vector(const Vector&);
	~Vector();

	// getters
	double getX() const {
		return pVec[0];
	}
	double getY() const {
		return pVec[1];
	}
	double getZ() const {
		return pVec[2];
	}

	// setters
	void setX(double x) {
		pVec[0] = x;
	}
	void setY(double y) {
		pVec[1] = y;
	}
	void setZ(double z) {
		pVec[2] = z;
	}

	// return magnitude of vector
	double magnitude() const {
		return sqrt(pVec[0]*pVec[0] + pVec[1]*pVec[1] + pVec[2]*pVec[2]);
	}

	Vector operator-();
  	bool operator<(const Vector&);
	bool operator==(const Vector&);
	Vector &operator=(const Vector &rhs);

private:
	const size_t VDIMENSION;
	double *pVec;
	void doCopy(const Vector&);

	friend double operator*(const Vector&, const Vector&);
	friend Vector operator*(const Vector&, double);
	friend Vector operator*(double, const Vector&);
	friend Vector operator+(const Vector&, const Vector&);
	friend Vector operator+(const Vector&, double);
	friend Vector operator+(double, const Vector&);
	friend Vector operator-(const Vector&, const Vector&);
	friend Vector operator-(const Vector&, double);
	friend Vector operator-(double, const Vector&);
	friend Vector operator^(const Vector&, const Vector&);
	friend ostream& operator<<(ostream&, const Vector&);
};

//=============================================================================
//            	END OF CONDITIONAL BLOCK
#endif
//=============================================================================
//             END OF HEADER FILE
//============================================================================= 


Pretty straight-forward stuff.

Class Implementation:
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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
//=============================================================================
// 				INCLUDE FILES
#include "VectorClass2.h"
#include <iostream>
using namespace std;
/*
 * default constructor
 * allocate memory for the three coordinates and initialize them to 0
 */
Vector::Vector()
: VDIMENSION(3) {
	pVec = new double[VDIMENSION];
	for (size_t i = 0; i < VDIMENSION; i++)
		pVec[i] = 0;
}

/*
 * parameterized constructor
 * allocate memory for the three coordinates and initialize them to the parameters
 */
Vector::Vector(double x, double y, double z)
: VDIMENSION(3) {
	pVec = new double[VDIMENSION];
	pVec[0] = x;
	pVec[1] = y;
	pVec[2] = z;
}

/*
 * copy constructor
 * performs deep copy
 */
Vector::Vector(const Vector &rhs)
: VDIMENSION(3) {
	pVec = new double[VDIMENSION];

	doCopy(rhs);
}

/*
 * overloaded assignment operator
 * performs deep copy assignment
 */
Vector &Vector::operator=(const Vector &rhs) {
	// check for self assignment
	if (this != &rhs)
		doCopy(rhs);

	return *this;
}

/*
 * does the actual copying of rhs to *this object
 */
void Vector::doCopy(const Vector &rhs) {

	// assign coordinates
	for (size_t i = 0; i < VDIMENSION; i++)
		pVec[i] = rhs.pVec[i];
}

/*
 * destructor
 * deallocate memory
 */
Vector::~Vector() {
	delete [] pVec;
}

/*
 * vector dot product
 */
double operator*(const Vector& a, const Vector& b) {

	return (a.getX() * b.getX() + a.getY() * b.getY() + a.getZ() * b.getZ());
}

/*
 * scalar multiplication
 */
Vector operator*(double a, const Vector& b) {
	Vector result;

	result.setX(a * b.getX());
	result.setY(a * b.getY());
	result.setZ(a * b.getZ());

	return result;
}

/*
 * scalar multiplication
 */
Vector operator*(const Vector& a, double b) {
	Vector result;

	result.setX(a.getX() * b);
	result.setY(a.getY() * b);
	result.setZ(a.getZ() * b);

	return result;
}

/*
 * vector addition
 */
Vector operator+(const Vector& a, const Vector& b) {
	Vector result;

	result.setX(a.getX() + b.getX());
	result.setY(a.getY() + b.getY());
	result.setZ(a.getZ() + b.getZ());

	return result;
}

/*
 * scalar addition
 */
Vector operator+(double a, const Vector& b) {
	Vector result;

	result.setX(a + b.getX());
	result.setY(a + b.getY());
	result.setZ(a + b.getZ());

	return result;
}

/*
 * scalar addition
 */
Vector operator+(const Vector& a, double b) {
	Vector result;

	result.setX(a.getX() + b);
	result.setY(a.getY() + b);
	result.setZ(a.getZ() + b);

	return result;
}

/*
 * vector substraction
 */
Vector operator-(const Vector& a, const Vector& b) {
	Vector result;

	result.setX(a.getX() - b.getX());
	result.setY(a.getY() - b.getY());
	result.setZ(a.getZ() - b.getZ());

	return result;
}


/*
 * scalar substraction
 */
Vector operator-(double a, const Vector& b) {
	Vector result;

	result.setX(a - b.getX());
	result.setY(a - b.getY());
	result.setZ(a - b.getZ());

	return result;
}

/*
 * scalar substraction
 */
Vector operator-(const Vector& a, double b) {
	Vector result;

	result.setX(a.getX() - b);
	result.setY(a.getY() - b);
	result.setZ(a.getZ() - b);

	return result;
}

/*
 * vector unary negation
 */
Vector Vector::operator-() {
	Vector result;

	result.setX(-getX());
	result.setY(-getY());
	result.setZ(-getZ());

	return result;
}

/*
 * scalar division
 */
Vector operator/(const Vector& a, double b) {
	Vector result;

	if (b != 0) {
		result.setX(a.getX() / b);
		result.setY(a.getY() / b);
		result.setZ(a.getZ() / b);
	}

	return result;
}

/*
 * vector cross product
 */
Vector operator^(const Vector& a, const Vector& b) {
	Vector result;

	result.setX(a.getY() * b.getZ() - a.getZ() * b.getY());
	result.setY(a.getZ() * b.getX() - a.getX() * b.getZ());
	result.setZ(a.getX() * b.getY() - a.getY() * b.getX());

	return result;
}

/*
 * vector equality
 */
bool Vector::operator==(const Vector &rhs) {
	return (getX() == rhs.getX() && getY() == rhs.getY() && getZ() == rhs.getZ());
}

/*
 * vector less than
 */
bool Vector::operator<(const Vector &rhs) {
	return (magnitude() < rhs.magnitude());
}

/*
 * overloaded insertion operator <<
 */
ostream& operator<<(ostream& os, const Vector& v) {
	os << "[ " << v.getX() << ", " << v.getY() << ", " << v.getZ() << " ]";
	return os;
}


And the Menu Driver:
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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
// 				INCLUDE FILES
#include <iostream>
#include <iomanip>
#include "VectorClass2.h"
using namespace std;

int main() {
	// 1. Declare three vector objects A, B, C with the  values [1.0,0.0,0.0] , [0.0,1.0,0.0] and [0.0,0.0,1.0] respectively. 
	Vector A(1.0, 0.0, 0.0),
		   B(0.0, 1.0, 0.0),
		   C(0.0, 0.0, 1.0);

	cout.precision(3);
	cout << fixed;
    cout << "1. Three Vectors: A, B, & C." << endl;

	// 2. Display the three vectors.
	cout << "2.  A = " << A << " = " << A.magnitude() << endl;
	cout << "    B = " << B << " = " << B.magnitude() << endl;
	cout << "    C = " << C << " = " << C.magnitude() << endl;

	// 3. Display the dot product of A and B. 
	cout << "3.  A * B = " << A * B << endl;
	
	// 4. Display the cross product of A and B.
	Vector crossAB = A ^ B;
	cout << "4.  A ^ B = " << crossAB << " = " << crossAB.magnitude() << endl;

	// 5. Display the cross product of B and A (The cross product is not commutative,
	//    you should get a different answer than you got for test 4.) 
	Vector crossBA = B ^ A;
	cout << "5.  B ^ A = " << crossBA << " = " << crossBA.magnitude() << endl;

	// 6. Perform the assignment statement, A = A * 3.27; and then display the value and magnitude of vector, A. 
	A = A * 3.27;
	cout << "6.  A = " << A << " = " << A.magnitude() << endl;

	// 7. Perform the assignment statement, B = 4.5 + B; and then display the value and magnitude of vector, B. 
	B = 4.5 + B;
	cout << "7.  B = " << B << " = " << B.magnitude() << endl;

	// 8. Perform the assignment statement, C = C – 1.36; and then display the value and magnitude of vector, C. 
	C = C - 1.36;
	cout << "8.  C = " << C << " = " << C.magnitude() << endl;

	// 9. Declare vector, D(A – B), and display D. 
	Vector D(A - B);
	cout << "9.  D = " << D << " = " << D.magnitude() << endl;

	// 10. Display A and B to ensure that their values didn’t change. 
	cout << "10. A = " << A << " = " << A.magnitude() << endl;
	cout << "    B = " << B << " = " << B.magnitude() << endl;

	// 11. Declare vector, E(B + C), and display E.
	Vector E(B + C);
	cout << "11. E = " << E << " = " << E.magnitude() << endl;

	// 12. Display B and C to ensure that their values didn’t change. 
	cout << "12. B = " << B << " = " << B.magnitude() << endl;
	cout << "    C = " << C << " = " << C.magnitude() << endl;

	// 13. Display the dot product of D and E. 
	cout << "13. D * E = " << D * E << endl;

	// 14. Display D and E to ensure that their values didn’t change. 
	cout << "14. D = " << D << " = " << D.magnitude() << endl;
	cout << "    E = " << E << " = " << E.magnitude() << endl;

	// 15. Display the cross product of D and E. 
	Vector crossDE = D ^ E;
	cout << "15. D ^ E = " << crossDE << " = " << crossDE.magnitude() << endl;
	
	// 16. Display D and E to ensure that their values didn’t change. 
	cout << "16. D = " << D << " = " << D.magnitude() << endl;
	cout << "    E = " << E << " = " << E.magnitude() << endl;

	// 17. Perform the unary negation operator on vector E and then display it 
	Vector negE = -E;
	cout << "17. -E = " << negE << " = " << negE.magnitude() << endl;

	// 18. A Unit vector is a vector that points in the same direction as the original vector,
	// but whose magnitude is unity (1). It is calculated by dividing the vector by its magnitude
	// (e.g., VectorA/VectorA.mag()).  Calculate and display the Unit vector for E. 
	Vector unitE = E / E.magnitude();
	cout << "18. Unit vector of E = " << unitE << " = " << unitE.magnitude() << endl;

	// 19. Display the result (i.e., true or false – NOT 1 or 0) of the operation, A = = B. 
	cout << "19. A == B = " << ((A == B)? "true": "false") << endl;

	// 20. Display the result (i.e., true or false – NOT 1 or 0) of the operation,  D < E.
	cout << "20. D < E = " << ((D < E)? "true": "false") << endl;

	// 21. Perform the cascaded assignment A = B = C = Vector(1.5, 2.5, 3.5); and then display all of 
	// these vector objects to verify they are indeed equal.
	A = B = C = Vector(1.5, 2.5, 3.5);
	cout << "21. A = " << A << " = " << A.magnitude() << endl;
	cout << "    B = " << B << " = " << B.magnitude() << endl;
	cout << "    C = " << C << " = " << C.magnitude() << endl;

	return(0);
}


Did I copy/paste the code into the wrong spot? I've been looking at this for an hour now.
Topic archived. No new replies allowed.