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
|
#include <iostream>
using namespace std;
class Vector2D //Base
{
protected:
int x, y, a, b, c;
public:
Vector2D(int, int, int, int, int);
void print();
};
class Vector3D:public Vector2D //
{
private:
int z;
public:
Vector3D(int, int, int, int, int, int);
int DotProduct();
int CrossProduct();
void print();
};
Vector2D::Vector2D( int x1, int y1, int a1, int b1, int c1)
{
x = x1;
y = y1;
a = a1;
b = b1;
c = c1;
}
Vector3D::Vector3D(int x2, int y2,int z2, int a2,int b2, int c2)
:Vector2D(a2, b2, c2, x2, y2)
{
x = x2;
y = y2;
z = z2;
a = a2;
b = b2;
c = c2;
}
int Vector3D::DotProduct()
{
double dp = (x*a + y*b + z*c);
return dp;
}
int Vector3D::CrossProduct()
{
int d = ((y*c) - (z*b));
int e = ((z*a) - (x*c));
int f = ((x*b) - (y*a));
return *this;
}
void Vector3D::print()
{
cout << "\n\nThe dot product of < " << x <<", "<<y<<", "<< z
<<"> and <" << a <<", "<<b <<", "<<c <<"> is <" << DotProduct() <<">"<<endl;
cout << "\nThe cross product of <" << x <<", "<<y<<", "<< z
<<"> and <" << a <<", "<<b <<", "<<c <<"> is <" << d <<", "<< e <<", "<< f <<">";
//This line above i need help with i need to print 3 ints
}
int input(int&, int&, int&, int&, int&, int&);
int main ()
{
int x, y, z, a, b, c;
input(x, y, z, a, b, c);
Vector3D S2(x, y, z, a, b, c);
S2.print();
return 0;
}
int input(int& x, int& y, int& z, int& a, int& b, int& c)
{
cout << "Enter values for x, y, and z: ";
cin >> x >> y >> z;
cout << "\n\nEnter values for a, b, and c: ";
cin >> a >> b >> c;
return x, y, z, a, b, c;
}
|