Archived

This topic is now archived and is closed to further replies.

Ambiguous symbol?

This topic is 5147 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

i think it means something along the lines of the compile has found the symbol but its found more than one version of it and isnt sure which to use.

try changing it to std::cout as thats fixed the problem for me in the past (and also stopped me doing ''using namespace std;'' in my code in favour of std:

Share this post


Link to post
Share on other sites
Well I use a library to parse a .wrl file . The code is not mine but I use it to convert the .wrl file to points and triangles.

This is the code :

#include <PQP.h>
#include <vrsVRML2.h>
#include <vrsBaseNode.h>
#include <vrsGeometryNode.h>
#include <vrsTransformNode.h>
#include <vrsTree.h>



//Main function
void main()
{
// Helpful variables for parsing the vrml file
tree mytree;
tree::iterator iter,end,root;
vrsVrml2 vrml;
vrsBaseNode vrmlNode;
vrsXform xform;
vrsGeometryNode *geometry;
float (*points)[3]=NULL;
int (*tris)[3]=NULL;
int nPoints ;
int nTris;

root=mytree.begin();
vrml.setFilename("X_chair15.WRL");
iter = mytree.insert(root,&vrmlNode);
vrml.parse(&mytree, iter);

iter=mytree.begin();
end=mytree.end();

for (; iter!=end;++iter )
{

NodeType mType = (*iter)->getType();
switch (mType){
case GEOMETRY:
{
geometry=(vrsGeometryNode*)(*iter);
nPoints = geometry->getNumPoints();
nTris = geometry->getNumTris();
points= new float[nPoints][3];
tris= new int[nTris][3];
geometry->getHapticGeom(points);
geometry->getHapticIndex(tris);

}
break;
}

}



printf("%f" , points[71][2] ) ;
printf("%d" , nPoints ) ;
float y = points[12][2];
printf("%f" , y);
cout << y << endl;

}

The printing with printf() works fine but with "cout" gives this error. Also when in an OpenGL application try to do something like this :
glBegin(GL_POINT);
glVertex3f(points[0][0] , points[0][1] , points[0][2] );
glEnd();

after I have used the above code to load the .wrl , it doesn''t appear anything on screen . I think that these two problems are connected somehow.
Thanks

Share this post


Link to post
Share on other sites
You haven''t included the iostreams header. Add these two lines:

#include <iostream>
using std::cout;
using std::endl;

The OpenGL problem is almost certainly unrelated.


"Sneftel is correct, if rather vulgar." --Flarelocke

Share this post


Link to post
Share on other sites
Ok both problems were solved ( thanks for the answers) but I have another small question. In code there is this:

float (*points)[3]=NULL;

and then this:

points= new float[nPoints][3];

What exactly the first defines (an array of float pointers or something else) and how can I delete the memory which is locked with the second? I don''t quite understand what happens.
Thanks

Share this post


Link to post
Share on other sites
quote:
Original post by mits
float (*points)[3] = NULL;

Yes, this creates an array of 3 pointer-to-floats's.

quote:
Original post by mits
points= new float[nPoints][3];

This is not a valid statement.

[edited by - chacha on November 11, 2003 5:49:30 AM]

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
I am not the OP, but in the above post there is these two lines:

float (*points)[3] = NULL;

1) What would points hold? A pointer to the first element in the array? If that is so, then wouldn''t points point to the first pointer in the array? (ie: does points point to &points[0] ??).

2) What would *points refer to?

Share this post


Link to post
Share on other sites
To chacha:

points = new float[nPoints][3];


I don''t know if that is valid code , but in a sample program I''ve got , it uses it this way and then it treats ''points'' like a 2d array e.g points[1][2]. So how else can I use ''new'' with that in order to have a 2d array at the end?And then how I delete it?

Thanks

Share this post


Link to post
Share on other sites
quote:

float (*points)[3]=NULL;
points= new float[nPoints][3];
This is not a valid statement.



MSVC++ 6.0 SP5 compiles it fine.

It''s not code that I''d write. This is the same code with equivalent typedefs, I believe.

typedef float FLOATARRAY3[3];
typedef FLOATARRAY3* PFLOATARRAY;
PFLOATARRAY points = NULL;
// or

FLOATARRAY *points2 = NULL;
// or

float (*points3)[3] = NULL;

quote:

AP : What would points hold?


The above makes it clear I think.


points = new FLOATARRAY3[nPoints];
// or

points2 = new float[nPoints][3];


quote:

So how else can I use ''new'' with that in order to have a 2d array at the end?And then how I delete it?




float **ppf = NULL; // Pointer to pointer to float

const unsigned long columns = 20;
const unsigned long rows = 11;

// Allocate the columns

ppf = new float*[columns];

// Allocate the rows

for (x = 0; x < columns ; ++x)
{
ppf[x] = new float[rows];
}

// You now have a 2 dimensional array of size cloumns X rows

// that you can access like ppf[2][5], from ppf[0][0] to ppf

// [columns - 1][rows - 1], i.e. ppf[19][10]


ppf[3][7] = 0.5f; // Use our array, (uselessly in this case)


// Delete all the rows

for (x = 0; x < columns ; ++x)
{
delete [] (ppf[x]);
}

// Delete all the columns

delete [] ppf;
ppf = NULL;


I haven''t tested that code, but that should give you an idea.

Ro_Akira

Share this post


Link to post
Share on other sites