Jump to content
  • Advertisement
Sign in to follow this  
FGFS

no matching function for call to

This topic is 2027 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi

 what could be my fault with:

 

    meshes.push_back(new mesh::mesh(&data,&indices,&textures));

 

I get that error:

 

Multiple markers at this line
    - expected ‘)’
    - no matching function for call to
     ‘std::vector<mesh*>::push_back(int*)’
    - expected type-specifier
    - candidate is:
    - Line breakpoint: sceneLoader.cpp [line: 107]

 

 

Many thanks

 

Share this post


Link to post
Share on other sites
Advertisement
Remove mesh:: unless the mesh class is placed inside a namespace named mesh.

Share this post


Link to post
Share on other sites

I get with:

    meshes.push_back(new mesh(&data,&indices,&textures));

the errors below. Thanks again.

 

 

Multiple markers at this line
    - Line breakpoint: sceneLoader.cpp [line: 107]
    - candidate is:
    - Invalid arguments ' Candidates are: void push_back(mesh * const &)
     '
    - no matching function for call to
     ‘std::vector<mesh*>::push_back(int*)’
    - expected ‘)’ before ‘mesh’
    - expected type-specifier before ‘mesh’

Share this post


Link to post
Share on other sites

Try to write the smallest possible program that reproduces the error. In the process you will probably figure out the problem yourself. If you don't, you can then post that minimal complete program here and we will be able to help you much much better.

 

Also, why are you using pointers all over the place? Life is better if you use containers of objects, not containers of pointers. And why does the constructor of mesh take pointers? If it's to avoid making copies, you should pass by const reference instead.

Edited by Álvaro

Share this post


Link to post
Share on other sites


Hi

what could be my fault with:



meshes.push_back(new mesh::mesh(&data,&indices,&textures));

 

The problem is somewhere else, since this code compiles fine:

#include <vector>

struct mesh {
  mesh(int *, int *, int *) {
  }
};

int main() {
  std::vector<mesh *> meshes;
  int data=1, indices=2, textures=3;

  meshes.push_back(new mesh(&data, &indices, &textures));
}

Share this post


Link to post
Share on other sites

Looks like the compiler can't see the definition of mesh. It thinks new mesh is returning an int* not a mesh*.

 

as I've said before.. yes, because mesh is not defined.. thus it's missing the mesh.h include... mesh is probably forward declared, the compiler defaults to int, so new mesh becomes a possible int*.

It's one of the dumbest error messages a compiler can output.

Share this post


Link to post
Share on other sites

If I only provide a forward declaration for mesh, my compiler (g++ 4.7.1) says:

 

kk.cpp: In function ‘int main()’:
kk.cpp:16:55: error: invalid use of incomplete type ‘struct mesh’
kk.cpp:10:8: error: forward declaration of ‘struct mesh’
 

I guess the OP's compiler is particularly unhelpful.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!