Saturday 18 August 2018

c++ - cannot access argv value in functions that are initialized in constructor

Unable to access argv value in parseCmdline function in myarm.cpp which is initialized in the constructor.
Don't know how to pass/initialize the value from main(int argc, char *argv[ ]) in constructor?



main.cpp




#include "myarm.h"    
int main(int argc, char *argv[]){
cout<<"argv is:"< MyArm arm;


myarm.cpp



#include "myarm.h"


MyArm::MyArm(){
nj = 0;
done = false;
times = 0;
count = 50;
which_joint = 0;
cout<<"argv is:"< parseCmdline();
}


int MyArm::parseCmdline() {
params.fromCommand(argc, argv);
if (!params.check("robot")){
cout<<"Please specify name of the robot"< cout<<"--robot name (e.g. TechNit)"< return 1;
}

else if(!params.check("element")){
cout<<"Please specify name of the element"<
cout<<"--element name (e.g. left_arm)"< return 1;
}
}

No comments:

Post a Comment

php - file_get_contents shows unexpected output while reading a file

I want to output an inline jpg image as a base64 encoded string, however when I do this : $contents = file_get_contents($filename); print &q...