Das folgende Code-Beispiel stammt aus dem Buch
 
  Objektorientiertes Programmieren in C++
  - Ein Tutorial für Ein- und Umsteiger
 von Nicolai Josuttis, Addison-Wesley München, 2001
 
  © Copyright Nicolai Josuttis 2001
#include <iostream>
#include <string>
#include <cstdlib>
#include "lexcast.hpp"
int main (int argc, char* argv[])
{
    try {
        if (argc > 1) {
            // erstes Argument als int auswerten
            int wert = lexical_cast<int>(argv[1]);
            // int als String verwenden
            std::string msg;
            msg = "Der uebergebene Wert ist: "
                  + lexical_cast<std::string>(wert);
            std::cout << msg << std::endl;
        }
    }
    catch (const char* msg) {
        std::cerr << "Exception: " << msg << std::endl;
        return EXIT_FAILURE;
    }
}