You are trying to complicate a simple matter. Try
#include <iostream>
#include <vector>
using namespace std;
int dot(const vector<int> & a, const vector <int> &b)
{
int dp = 0;
for (size_t n = 0; n< a.size(); ++n)
{
dp += a[n]*b[n];
}
return dp;
}
int main()
{
vector<int> a={0,0,7,0,5,0,0,8,0,4};
vector<int> b={0,0,0,5,6,0,0,0,0,5};
int dp = dot(a,b);
cout << "result = " << dp << endl;
}