C++ string to enum

A std::map<std::string, MyEnum> (or unordered_map) could do it easily. Populating the map would be just as tedious as the switch statement though. Edit: Since C++11, populating is trivial:

C++ Class ‘undeclared identifier”

This is really frustrating, I’ve tried multiple variations of my class and constructor, sifted through pages of google results and other questions on this site but I can’t figure it out. I believe the error is something simple that I’m overlooking. Error code: student.h student.cpp main.cpp Just as a note, my professor said adding #include … Read more

PlaySound in C++ Console application?

How can I play sounds without freezing the console? If you Google for PlaySound this is the first result: fdwSound … SND_ASYNC The sound is played asynchronously and PlaySound returns immediately after beginning the sound. To terminate an asynchronously played waveform sound, call PlaySound with pszSound set to NULL. You should familiarise yourself with search … Read more

extended initializer lists only available with

This style of initialisation, using braces: was introduced to the language in 2011. Older compilers don’t support it; some newer ones (like yours) only support it if you tell them; for your compiler: However, this form of initialisation still isn’t valid for arrays created with new. Since it’s small and only used locally, you could … Read more

Error: C2228: left of ” must have class/struct/union

You made an error here: You declared a function called myDBControl taking no arguments and returning a DatabaseControl. Object declarations without any constructor arguments must omit the (): This is related to (but is not precisely) the “most vexing parse“, in that it’s caused by the same language rule that statements are function declarations if … Read more