Ambiguous symbol?

Started by
8 comments, last by mits 20 years, 5 months ago
I use cout to print a variable on screen and I get this error: " "cout" is an ambiguous symbol " . What''s wrong? Thanks
Advertisement
You''ll have to post your code.

"Sneftel is correct, if rather vulgar." --Flarelocke
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:
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
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
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
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]
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?
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
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;// orFLOATARRAY *points2 = NULL;// orfloat (*points3)[3] = NULL;

quote:
AP : What would points hold?

The above makes it clear I think.

points = new FLOATARRAY3[nPoints];// orpoints2 = 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 floatconst unsigned long columns = 20;const unsigned long rows = 11;// Allocate the columnsppf = new float*[columns];// Allocate the rowsfor (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 rowsfor (x = 0; x < columns ; ++x){   delete [] (ppf[x]);}// Delete all the columnsdelete [] ppf;ppf = NULL;


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

Ro_Akira

This topic is closed to new replies.

Advertisement