• Saves Valuable Time
  • Trusted Accuracy for 14 Years
  • 15-Day Money-Back Guarantee

C++ Equivalent to VB Dictionary

The nearly exact C++ equivalent to .NET's Dictionary collection is the std::unordered_map collection.

VB C++
Imports System.Collections.Generic

Sub Dictionaries()
    Dim map As New Dictionary(Of String, Integer)()
    Dim s As String = "test"
    map.Add(s, 1)
    Dim i As Integer = map(s)
    i = map.Count
    Dim b As Boolean = map.Count = 0
End Sub
#include <string>
#include <unordered_map>

void Dictionaries()
    std::unordered_map<std::wstring, int> map;
    std::wstring s = L"test";
    map.emplace(s, 1);
    int i = map[s];
    i = map.size();
    bool b = map.empty();

Use VB to C++ Converter to convert from VB to C++.     

Additional resource: VB.NET and C++ Equivalents

Copyright © 1997 – 2018 Tangible Software Solutions Inc.