好吧,我已经更新了我的代码,但我仍然不确定如何使用我传递的命令行参数的向量.我试着像我下面的代码一样设置它,但它不会编译.它给我一个错误,它无法找到argc和argv:
1> c:\ users\chris\documents\visual studio 2008\projects\cplusplustwo\cplusplustwo\application.h(32):错误C2065:'argc':未声明的标识符1> c:\ users\chris\documents\visual studio 2008\projects\cplusplustwo\cplusplustwo\application.h(32):错误C2065:'argv':未声明的标识符
main.cpp中
#include "application.h"
int main(int argc,char *argv[]){
vector<string> args(argv, argv + argc);
return app.run(args);
}
Run Code Online (Sandbox Code Playgroud)
application.h
#include <boost/regex.hpp>
#include <iostream>
#include <string>
#include <fstream>
#include <sstream>
#include "time.h"
using namespace std;
class application{
private:
//Variables
boost::regex expression;
string line;
string pat;
string replace;
int lineNumber;
char date[9];
char time[9];
void commandLine(vector<string> args){
string expression=""; // Expression
string textReplace=""; // Replacement Text
string inputFile=""; // Input File
string outputFile=""; // Output …Run Code Online (Sandbox Code Playgroud)