It seems you want to create a class specifically for vectors. The class I made in my example is adapted to 3-dimensional vectors, but you can change it to another if you wish. The class has i, j, k, but can also perform scalar products based on other MathVectors. Another vector is passed through a C ++ link. It is difficult to deduce the question, but I think that could answer it.
#include <iostream> using namespace std; class MathVector { private: double i,j,k; public: MathVector(double i,double j,double k) { this->i=i; this->j=j; this->k=k; } double getI(){return i;} double getJ(){return j;} double getK(){return k;} double scalar(MathVector &other) { return (i*other.getI())+(j*other.getJ())+(k*other.getK()); } }; int main(int argc, char **argv) { MathVector a(1,2,5), b(2,4,1); cout << a.scalar(b) << endl; return 0; }
jakebird451
source share