Static Methods

To promote cohesion, static methods are oftened gathered together in one class, as in the Nim project's Utils class. Here is the header file:

class Utils {
public:
    static string intToString(int i);
    static int generateRandomInt(int min, int max);
};

Here is the implementation file

string Utils::intToString(int i) {
    stringstream out;
    out << i;
    return out.str();
}

int Utils::generateRandomInt(int min, int max) {
    return rand() % (max - min + 1) + min;
}