Simple string parsing with C++

This is a try using only standard C++. Most of the time I use a combination of std::istringstream and std::getline (which can work to separate words) to get what I want. And if I can I make my config files look like: foo=1,2,3,4 which makes it easy. text file is like this: And you parse … Read more

C++ getInt() function (have a java equivalent attached)

You just try to read an int with cin >> [int variable], and make sure it succeeded. If not, wash, rinse, and repeat: That will work, but will return 12 when given input like 12 a because it will read the 12 and stop at a. If you do not want to just “get as much as you can” and want … Read more

Is string::compare reliable to determine alphabetical order?

According to the docs at cplusplus.com, The member function returns 0 if all the characters in the compared contents compare equal, a negative value if the first character that does not match compares to less in the object than in the comparing string, and a positive value in the opposite case. So it will sort … Read more

Undefined reference to class constructor, including .cpp file fixes

The undefined reference error indicates that the definition of a function/method (i.e constructor here) was not found by the linker. And the reason that adding the following line: fixes the issue, is it brings in the implementation as part of the main.cpp whereas your actual implementation is in StaticObject.cpp. This is an incorrect way to fix this problem. I haven’t used Netbeans … Read more