?
Solved

Compile Error: C2668 ambiguous call to overloaded function

Posted on 2003-03-16
5
Medium Priority
?
1,636 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

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

Templates For Beginners Or How To Encourage The Compiler To Work For You Introduction This tutorial is targeted at the reader who is, perhaps, familiar with the basics of C++ but would prefer a little slower introduction to the more ad…
  Included as part of the C++ Standard Template Library (STL) is a collection of generic containers. Each of these containers serves a different purpose and has different pros and cons. It is often difficult to decide which container to use and …
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…
Suggested Courses
Course of the Month13 days, 11 hours left to enroll

800 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