Cannot convert `double*' to `double' for argument `1' to `void dotProduct(double, double, int)'. - ERROR

I hope I posted this help request in the correct forum, if not I'll get it right next time around. Any case onto my problem :

The following program is suppose to calculate the dot product of two vectors using three files (two .cpp files and one .h file).

Here is my code up to now :

prac7hw2.cpp (OR Main.cpp file)

#include <iostream>

#include "dotProduct.h"

using namespace std;

int main()
{
int size;
double vectorX[20];
double vectorY[20];

cout << "Please enter the size of the vectors: ";
cin >> size;

for (int i = 0; i < size; i++)
{
cout << "Please enter a value for element " << i << " of the first vector: ";
cin >> vectorX[i];
cout << "Please enter a value for element " << i << " of the second vector: ";
cin >> vectorY[i];
}

cout << "The result of the dot product is " << dotProduct(vectorX, vectorY, size) << endl;
}

dotProduct.h (Header file)

#ifndef dotProduct_H
#define dotProduct_H

double dotProduct(double vectorX, double vectorY, int size);

#endif

dotProduct.cpp (Second .cpp file)

dotProduct(vectorX,vectorY,size)
{
for(i=0;i<=size;i++)
{
return vectorX[i]*vectorY[i];
}

When I try to compile prac7hw1.cpp it gives me the following error :

Cannot convert `double*' to `double' for argument `1' to `double dotProduct(double, double, int)'.

I've Googled and FAQ'd and Textbook'd this error from every angle but I just can't find a solution.

Any help would be greatly appreciated. :-)
Try changing this:
double dotProduct(double vectorX, double vectorY, int size);
to:
double dotProduct(double vectorX[], double vectorY[], int size);
You're passing array pointers when you setupt the function to only except individual elements. You need to rewrite the function to except an array. See the last section of this tutorial page: http://www.cplusplus.com/doc/tutorial/arrays/
Ah. I see what you did there.

Gracias guys.

Appreciate the rapid response.
No problem :)
Topic archived. No new replies allowed.