Post: [SPRX/C++] Using 'Dictionaries' in C++ (maps)
06-24-2015, 07:33 AM #1
Hash847
Purple God
(adsbygoogle = window.adsbygoogle || []).push({});
I thought I might make a tutorial on how to use Dictionaries (from C#) in C++, except in C++ they're called maps.
In C# it's as simple as

     
Dictionary<string, string> Dictionary = new Dictionary<string, string>() = {
{ "Test", "Output!" },
};

And then you can do

     
string X = Dictionary["Test"];

I really liked doing things this way. It kept things really neat and clean when making programs that require a lot of variables instead of just having a cluster fuck of them.

So how do we do this in C++ in our SPRX's? Quiet easy really, and not the much different.

    
#include <map>

std::map<char*, int> MapExample;

void Function() {
MapExample["Test"] = 1;
}

int ReturnFunction() {
return MapExample["Test"]; //Will return 1
}


How simple is that?


I thought I'd make a small tutorial and see if anyone actually uses it to clean up their menus a little bit, since you can make a menubase incorporating this and it'll be quiet clean Winky Winky


edit: if you feel like calling them dictionaries you can do this:

    
typedef std::map Dictionary;

Dictionary<char*, char*> Dictionary;


Should work the same!

(adsbygoogle = window.adsbygoogle || []).push({});

The following 6 users say thank you to Hash847 for this useful post:

Boliberrys, Joren, Kryptus, John, Code
06-24-2015, 07:45 AM #2
Code
Banned
Originally posted by Pancake
I thought I might make a tutorial on how to use Dictionaries (from C#) in C++, except in C++ they're called maps.
In C# it's as simple as

     
Dictionary<string, string> Dictionary = new Dictionary<string, string>() = {
{ "Test", "Output!" },
};

And then you can do

     
string X = Dictionary["Test"];

I really liked doing things this way. It kept things really neat and clean when making programs that require a lot of variables instead of just having a cluster fuck of them.

So how do we do this in C++ in our SPRX's? Quiet easy really, and not the much different.

    
#include <map>

std::map<char*, int> MapExample;

void Function() {
MapExample["Test"] = 1;
}

int ReturnFunction() {
return MapExample["Test"]; //Will return 1
}


How simple is that?


I thought I'd make a small tutorial and see if anyone actually uses it to clean up their menus a little bit, since you can make a menubase incorporating this and it'll be quiet clean Winky Winky


edit: if you feel like calling them dictionaries you can do this:

    
typedef std::map Dictionary;

Dictionary<char*, char*> Dictionary;


Should work the same!




Thx for hax codez 4 me to copy n paste in2 my sprx b4se thx tears
06-24-2015, 01:43 PM #3
mrtn
Little One
can i have CL plz based h4x0r tears
09-27-2016, 07:53 AM #4
Shark
Retired.
Originally posted by Not
I thought I might make a tutorial on how to use Dictionaries (from C#) in C++, except in C++ they're called maps.
In C# it's as simple as

     
Dictionary<string, string> Dictionary = new Dictionary<string, string>() = {
{ "Test", "Output!" },
};

And then you can do

     
string X = Dictionary["Test"];

I really liked doing things this way. It kept things really neat and clean when making programs that require a lot of variables instead of just having a cluster fuck of them.

So how do we do this in C++ in our SPRX's? Quiet easy really, and not the much different.

    
#include <map>

std::map<char*, int> MapExample;

void Function() {
MapExample["Test"] = 1;
}

int ReturnFunction() {
return MapExample["Test"]; //Will return 1
}


How simple is that?


I thought I'd make a small tutorial and see if anyone actually uses it to clean up their menus a little bit, since you can make a menubase incorporating this and it'll be quiet clean Winky Winky


edit: if you feel like calling them dictionaries you can do this:

    
typedef std::map Dictionary;

Dictionary<char*, char*> Dictionary;


Should work the same!



works very good m8 Sal
You must login or register to view this content.

The following user thanked Shark for this useful post:

RouletteBoi

Copyright © 2026, NextGenUpdate.
All Rights Reserved.

Gray NextGenUpdate Logo