|
-
October 10th, 2012, 03:14 PM
#6
Re: PHP array in C++ ?
I think I missed some things here. What you want is probably more like this
Code:
#include <map>
#include <string>
struct Point
{
int x;
int y;
int z;
};
std::map< std::string, Point > models;
int distance( const std::string& objName1, const std::string& objName2 )
{
int x1 = models[objName1].x;
int x2 = models[objName2].x;
//Function that actually does something
return 0;
}
int main()
{
models["object1"].x = 7831;
models["object1"].y = 0;
models["object1"].z = 0;
models["object2"].x = 1893;
models["object2"].y = 0;
models["object2"].z = 0;
int dist = distance( "object1", "object2" );
return 0;
}
http://cplusplus.com/reference/string/string/
http://cplusplus.com/reference/stl/map/
Last edited by S_M_A; October 11th, 2012 at 02:28 AM.
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|