views:

193

answers:

2

I have a function to display the values of a vector in a table, but I keep getting an "Undefined symbols" error when linking.

Here is my function prototype:

void displayVectors(vector<string> & nameVec, vector<double> & scoreVec, vector<char> & gradeVec);

Here is the definition:

void dipslayVectors(vector<string> & nameVec, vector<double> & scoreVec, vector<char> & gradeVec) {

    for (int i = 0; i < nameVec.size(); i++) {
     cout << setw(12) << nameVec[i]
      << setw(8) << scoreVec[i]
      << setw(2) << gradeVec[i]
      << endl;
    }

}

Here's where I called it:

displayVectors(nameVec, scoreVec, gradeVec);

I'm certain nameVec, scoreVec, and gradeVec are all the right types of vectors, and I have all the libraries included, so I'm stumped. I've seen other people on Google have problems with vectors like this, but they always found some error they made. Does anyone have any ideas?

+2  A: 

Assuming you cut & pasted your question directly, then void dipslayVectors is a misspelling in the definition

Steve De Caux
It's always the minor details...
Adam Luchjenbroers
yeah... SO is great for a second set of eyeballs when you're working alone
Steve De Caux
I stared so long at them in my code, and didn't see any spelling errors, and when you pointed it out, I still had to look at it for about 20 seconds... Wow, it is so late... thanks!The weird part was it never actually pointed out the error in red like it usually does when finding errors while compiling. Then, I hit some other debug key, and it informed me that it hasn't been defined.
eds
Spelling errors jump out at me -- and I was about to edit it because I thought it was a typo in your example rather than your actual code. I'm glad I didn't "fix" that!
quark
A: 

From your code there may be 2 possible source of errors :

1.dipslayVectors is mispelled.

2.you might not have defined actual parameters.

3.One suggestion is make function const since its only reading the data and make formal parameter as reference to const data.

Ashish