I had started to learn 'vectors in c++' but my first program stops like this...
//Program to print dot product of two vector
#include<iostream>
using namespace std;
class vector{
public:
int *arr;
int size;
vector (int m){
size=m;
arr= new int[size];
}
int dotProduct(vector &v){
int d = 0;
for(int i=0; i <size; i++){
d += this->arr[i]*v.arr[i];
}
return 0;
}
};
int main()
{
vector v1(3);
v1.arr[0]=4;
v1.arr[1]=3;
v1.arr[2]=1;
vector v2(3);
v2.arr[0]=1;
v2.arr[1]=0;
v2.arr[2]=1;
int a=v1.dotProduct(v2);
cout<<a<<endl;
return 0;
}
It shows this as an error. 'v2' was not declared in this scope.
Another one is: class vector reference to 'vector' is ambiguous