/////////////////////////////////////////////////////////////// // vec.cpp - tests a 3 Dimensional vector template // // ver 1.1 // // Language: Visual C++, ver 7.0 // // Platform: Dell Dimension 8100, Windows 2000, SP 2 // // Application: Demonstration for CSE687, Spring 2003 // // Author: Jim Fawcett, CST 2-187, Syracuse Univ // // (315) 443-3948, jfawcett@twcny.rr.com // /////////////////////////////////////////////////////////////// #include #include #include "vec.h" using namespace std; using namespace LVS_3D; #ifdef TEST_VEC #include //----< helper functions >------------------------------------- string title(const string& s) { string temp(s.length()+2,'='); return (string("\n ") + s + string("\n ") + temp + "\n"); } string subtitle(const string& s) { string temp(s.length()+2,'-'); return (string("\n ") + s + string("\n ") + temp + "\n"); } //----< test stub >-------------------------------------------- int main() { cout << title("Testing 3D Vector Class"); cout << subtitle("vec operations:"); vec v1(1,1,1); v1.show("v1"); vec v2(2,2,2); v2.show("v2"); vec v3 = v1 + v2; v3.show("v3 = v1 + v2"); cout << "\n size of v3 = " << v3.size(); v1 = v3; v1.show("v3 = v1"); vec v4(1,1.5,2); v4.show("v4"); vec v5 = 0.33333 * v4; v5.show("0.33333 * v4 = v5"); v1.show("v1"); v2.show("v2"); cout << " inner product (v1,v2) = " << (v1,v2); cout << endl; cout << subtitle("vec operations"); vec v6(1,1,1); v6.show("v6"); vec v7(-2,-2,-2); v7.show("v7"); vec v8 = v6 - v7; v8.show("v8 = v6 - v7"); cout << "\n size of v8 = " << v8.size(); cout << "\n\n"; return 0; } #endif