Assigning atomic number based on atomic symbol
The most efficient way is to use unordered_map since C++11:

int main(int argc, const char * argv[]) {
    std::unordered_map&lt;std::string, unsigned int&gt; symbol_to_number = {
        {"H",  1},
        {"He", 2},
        {"Li", 3},
        // And so on..
    };

    // Usage:
    std::cout &lt;&lt; symbol_to_number["H"] &lt;&lt; std::endl;
    return 0;
}


Above, you get the number out of a symbol in constant time which improves on going through a lot of if statements.