DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

+ Reply to Thread
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, 07:03 PM
  2. map and memory leak
    By WXY595 in forum C++
    Replies: 3
    Last Post: 05-16-2007, 03:06 PM
  3. Drawing a map
    By chagen in forum .NET
    Replies: 2
    Last Post: 01-28-2006, 11:10 PM
  4. Replies: 3
    Last Post: 01-28-2006, 07: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, 10:21 AM

Bookmarks

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


Top DevX Stories

Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL


Sponsored Links