// Oldham, Jeffrey D. // 2000 Feb 21 // CS1321 // Mathematical Vector Use #include #include // has EXIT_SUCCESS #include "mvector.h" int main() { cout << "Hello, world.\n"; MVector m; cout << "An empty vector's original size is " << m.size() << ".\n"; m.resize(3); cout << "The vector should now have three elements: " << m.size() << "\n"; m.set(0, 1.1); m.set(1, 2.1); m.set(2, 3.1); cout << "The vector's contents: " << m << endl; MVector n(m); cout << "The copied vector's contents should be the same: " << n << endl; MVector p(3); cout << "A vector declared with size 3 has size " << p.size() << ".\n"; p.set(0, 4.1); p.set(1, 5.1); p.set(2, 6.1); cout << "The second vector's contents: " << p << endl; // test the arithmetic operations cout << "addition: " << m + p << endl; cout << "subtraction: " << m - p << endl; cout << "dot product: " << m * p << endl; cout << "scale by 2: " << 2 * m << endl; cout << "again: " << m * 2 << endl; cout << "add second vector to first, changing first vector: "; m += p; cout << m << endl; cout << "scale first vector, changing it: "; m *= 2; cout << m << endl; // test the relational operators if ((m == m) && !(m != m)) cout << "A vector equals itself.\n"; if ((m != p) && !(m == p)) cout << "Two different vectors are not equal.\n"; cout << "Goodbye, world.\n"; return EXIT_SUCCESS; }