Trouble with structures

May 25, 2012 at 11:54am
Lately Ive been modifying a Wavefront Obj model loader to use textures and Im modifying the "Face" structure to incorporate the texture coordinates into the face but i keep on getting this error

In file included from Video:20,
from Kernel.cpp:15:
Loader:58: error: ‘face::face(int, int, int, int, int)’ cannot be overloaded
Loader:48: error: with ‘face::face(int, int, int, int, int)’
Loader: In function ‘int loadObject(const char*)’:
Loader:170: error: no matching function for call to ‘face::face(int&, int&, int&, int&)’
Loader:48: note: candidates are: face::face(int, int, int, int, int)
Loader:41: note: face::face(const face&)

here is the original code
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24

struct face
{
 int facenum;
 bool four;
 int faces[4];

 face(int facen,int f1,int f2,int f3) : facenum(facen)//Constructor for triangle
 {  
  faces[0] = f1;
  faces[1] = f2;
  faces[2] = f3;
  four = false;
 }
 
 face(int facen,int f1,int f2,int f3,int f4) : facenum(facen)//Constructor for quad
 { 
  faces[0]=f1;
  faces[1]=f2;
  faces[2]=f3;
  faces[3]=f4;
  four=true;
 }
};


here is my modified code
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
struct face
{
 int facenum;
 bool four;
 int faces[4];
 int texcoord[4];
 int mat;
 
 face(int facen,int f1,int f2,int f3,int t1,int t2,int t3,int m) : facenum(facen)//Constructor for triangle
 {  
  faces[0] = f1;
  faces[1] = f2;
  faces[2] = f3;
  
  texcoord[0] = t1;
  texcoord[1] = t2;
  texcoord[2] = t3;
 
  mat = m;

  four = false;
 }
 
 face(int facen,int f1,int f2,int f3,int f4,int t1,int t2,int t3,int t 4,int m) : facenum(facen)//Constructor for quad
 { 
  faces[0]=f1;
  faces[1]=f2;
  faces[2]=f3;
  faces[3]=f4;

  texcoord[0] = t1;
  texcoord[1] = t2;
  texcoord[2] = t3;
  texcoord[3] = t4;

  mat = m;

  four=true;
 }
};


any help would be much appreciated
Last edited on May 25, 2012 at 2:59pm
May 25, 2012 at 11:58am
Are you sure you pass the correct number of arguments to the constructor?
May 25, 2012 at 12:39pm
I'm trying to add more arguments to it
May 25, 2012 at 1:19pm
closed account (zb0S216C)
Looks like ambiguity to me:

"Loader:58: error: ‘face::face(int, int, int, int, int)’ cannot be overloaded"

"Loader:170: error: no matching function for call to ‘face::face(int&, int&, int&, int&)’"

Wazzak
Last edited on May 25, 2012 at 1:19pm
May 25, 2012 at 2:19pm
And how would i fix this?
May 25, 2012 at 2:43pm
It's hard to say without seeing the real code.

int t 4 this doesn't look right.
May 25, 2012 at 2:58pm
*EDIT* still not working
Last edited on May 26, 2012 at 5:37pm
Topic archived. No new replies allowed.