Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

Compile Error: C2668 ambiguous call to overloaded function

Posted on 2003-03-16
5
Medium Priority
?
1,640 Views
Last Modified: 2012-06-27
After receiving this error, I checked out the suggestions on MSDN.  It said that it occurs from a templated function, of which I have none.  I double-checked to make sure my function prototype and definitions matched in number and type and found no problems there.  Perhaps an expert can enlighten me.

void setMatrix(vector< vector<float> >,float, float, float, float, float, float, float, float, float);

void setMatrix(vector< vector<float> > &m, float r1c1, float r1c2, float r1c3,
                  float r2c1, float r2c2, float r2c3, float r3c1, float r3c2, float r3c3)
{
     m[0][0] = r1c1;
     m[0][1] = r1c2;
     m[0][2] = r1c3;
     m[1][0] = r2c1;
     m[1][1] = r2c2;
     m[1][2] = r2c3;
     m[2][0] = r3c1;
     m[2][1] = r3c2;
     m[2][2] = r3c3;
}

setMatrix(myMatrix,
          0.0, 0.0, 0.0,
       0.0, 0.0, 0.0,
       0.0, 0.0, 0.0);
0
Comment
Question by:klax33
5 Comments
 
LVL 3

Expert Comment

by:Kashra
ID: 8149206
Well, technically, the use of vector<> does make your function a "templated" function. Afterall, vectors are templated and you're using them as a parameter. I think it would be useful if you could include the declaration and initialization of "myMatrix".
0
 

Author Comment

by:klax33
ID: 8149259
The declaration is:

vector< vector<float> > myMatrix(3, vector<float> (3));
0
 
LVL 1

Accepted Solution

by:
Hermetic earned 500 total points
ID: 8149346
I might be wrong, but your "overloaded function" probem seems to stem from the difference in your function prototype and your function declaration:

void setMatrix(vector< vector<float> >,float, float, float, float, float, float, float, float, float);

void setMatrix(vector< vector<float> > &m, float r1c1, float r1c2, float r1c3,
                 float r2c1, float r2c2, float r2c3, float r3c1, float r3c2, float r3c3)


one has a reference as the first argument the other doesn't.
0
 

Author Comment

by:klax33
ID: 8149381
That did it Hermetic.  Thank you for spotting the obvious.  I should have seen that.  Enjoy your points. :)
0
 

Expert Comment

by:e12voltsdac
ID: 8149387
Hermetic is correct.
You just forgot to put a & in your function declaration like this:

void setMatrix(vector< vector<float> > &,float, float, float, float, float, float, float, float, float);
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article will show you some of the more useful Standard Template Library (STL) algorithms through the use of working examples.  You will learn about how these algorithms fit into the STL architecture, how they work with STL containers, and why t…
Article by: evilrix
Looking for a way to avoid searching through large data sets for data that doesn't exist? A Bloom Filter might be what you need. This data structure is a probabilistic filter that allows you to avoid unnecessary searches when you know the data defin…
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.
Suggested Courses

571 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question