VC++ map


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 3 of 3

Thread: VC++ map

  1. #1
    Join Date
    Nov 2007
    Posts
    8

    VC++ map

    Hi guys,

    I'm having problems with using map in VC++, here is the function that I'm making:

    Code:
    void GLMesh::convertToDiffCoord(Mesh *m)
    {
    	//get the pointer to the list of pointers to all vertices
    	list<Vertex*>* v = m->get_vertices();
    
    	//initialize a map that will map each vertex pointer with an unique key
    	map<int, Vertex*> VMap;
    
    	//initialize iterator for the pointer list v
    	list<Vertex*>::iterator vi;
    
    	//iterate through the list and map each member in the list with a unique value
    	for (int i=0; i<v->size(); i++)
    		for(vi = v->begin(); vi != v->end(); vi++)
    			VMap[i] = v->[i];
    }
    I keep getting the error :"syntex error '[' ", any idea what's wrong?

  2. #2
    Join Date
    Nov 2003
    Posts
    4,118
    You probably want this:

    VMap[i] = v[i];

    v is a pointer, and pointers can be treated as array names.
    Danny Kalev

  3. #3
    Join Date
    Dec 2003
    Posts
    3,366
    -> breaks out class members; its used for a pointer to a multi-field variable.
    [] is how you get to a location in an array of the same object.

    and you can mix and match, an array of classes might give you
    thingy[10]->field = 3;

    you can also use * instead of [] to make you code uglier, you see this in C code or in c++ code written by C programmers.

Similar Threads

  1. Swapping a map element (a DOM question)
    By alsoares in forum AJAX
    Replies: 2
    Last Post: 12-20-2007, 08:03 PM
  2. map and memory leak
    By WXY595 in forum C++
    Replies: 3
    Last Post: 05-16-2007, 04:06 PM
  3. Drawing a map
    By chagen in forum .NET
    Replies: 2
    Last Post: 01-29-2006, 12:10 AM
  4. Replies: 3
    Last Post: 01-28-2006, 08:25 AM
  5. map areas not passing Form object to java script
    By mark hembree in forum ASP.NET
    Replies: 1
    Last Post: 01-11-2001, 11:21 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center