Forse dovresti concentrare la tua attenzione su argomenti più basilari, comunque per rispondere alla tua domanda: il codice usa la STL quindi puoi integrarlo sia in progetti MFC sia in progetti C++ standard.scusa ma il c++ lo sto imparando da poco.
Questo è un esempio di codice basato sulla classe in esame:
Puoi compilarlo sia dall'ambiente di sviluppo dopo aver incluso cmdline.cpp e cmdline.h nel progetto oppure da linea di comando: <compilatore> esempio.cpp cmdline.cpp, dove <compilatore> richiama il tuo compilatore (CL, G++, etc).codice:#include <iostream> #include "CmdLine.h" using namespace std; int main(int argc, char **argv) { // our cmd line parser object CCmdLine cmdLine; // parse argc,argv if (cmdLine.SplitLine(argc, argv) < 1) { // no switches were given on the command line, abort exit(-1); } // test for the 'help' case if (cmdLine.HasSwitch("-h")) { cout << "SINTASSI: ..." << endl; exit(0); } // get the required arguments StringType p1_1, p1_2, p2_1; try { // if any of these fail, we'll end up in the catch() block p1_1 = cmdLine.GetArgument("-p1", 0); p1_2 = cmdLine.GetArgument("-p1", 1); p2_1 = cmdLine.GetArgument("-p2", 0); } catch (...) { // one of the required arguments was missing, abort exit(-1); } // get the optional parameters // since opt2 has no arguments, just test for the presence of // the '-opt2' switch bool bOptVal2 = cmdLine.HasSwitch("-opt2"); // E via dicendo! }

Rispondi quotando