no matching function for call to

Started by
9 comments, last by kunos 10 years, 11 months ago

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

Advertisement
Remove mesh:: unless the mesh class is placed inside a namespace named mesh.

What Wooh said.. or you forgot to include mesh.h ?

Stefano Casillo
TWITTER: [twitter]KunosStefano[/twitter]
AssettoCorsa - netKar PRO - Kunos Simulazioni

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’

And have you followed kunos' advice as well?

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.


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));
}

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

"Most people think, great God will come from the sky, take away everything, and make everybody feel high" - Bob Marley

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.

Stefano Casillo
TWITTER: [twitter]KunosStefano[/twitter]
AssettoCorsa - netKar PRO - Kunos Simulazioni

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.

This topic is closed to new replies.

Advertisement