Saturday, August 18, 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

plot explanation - Why did Peaches&#39; mom hang on the tree? - Movies &amp; TV

In the middle of the movie Ice Age: Continental Drift Peaches' mom asked Peaches to go to sleep. Then, she hung on the tree. This parti...