Abstract
A C++ library to perform basic operations on vectors such as :
- vector addition
- vector subtraction
- dot product
- cross product
- distance between two points (2D/3D)
Background
Last sem, I took a course on Object Oriented Programming in C++ at my university. So I created this library with the objective of revising :
- Constructors
- operator overloading
- template functions and classes
- friend functions
- C++ build system using Makefiles
How to use?
To use the library, copy the vector.h header file in your project and include it in your source files.
- Initialize
Vector
#include<iostream>
#include "vector.h"
int main(){
Vector<float> o; // Origin : (0,0,0)
Vector<int> v(13,14,25);
return 0;
}- Basic operations: Vector addition, subtraction, increment and decrement

#include<iostream>
#include "vector.h"
int main(){
Vector<float> o; // Origin : (0,0,0)
Vector<int> v(13,14,25);
return 0;
}- Cross Product of two vectors

#include<iostream>
#include "vector.h"
int main(){
Vector<int> vectors[5];
for(int i=0;i<5;i++){
Vector<int> temp(i,i,i);
vectors[i] = temp;
}
// print all vectors
for(auto x :vectors){
std::cout << x << std::endl;
}
// OUTPUT
/*
(0,0,0)
(1,1,1)
(2,2,2)
(3,3,3)
(4,4,4)
*/
return 0;
}Advanced usage and more examples are provided in the GitHub repository.