c++ - Conversion warning. and Class error -


i'm learning c++, , in assignment i'm doing right now, bunch of warnings suspect causing 2 errors i'm getting well. problem lines warnings show lines (one of which) gave us, think code must right. leads me believe there issue in class declaration or constructor. can spot wrong?

the warning (for each line of fillsystemcommandlist function) conversion string literal 'char *' deprecated

and errors undefined symbols architecture x86_64: "command::command(char*, int)", referenced from: fillsystemcommandlist() in system_utilities.o ld: symbol(s) not found architecture x86_64 clang: error: linker command failed exit code 1 (use -v see invocation)

you can skip on parsecommandline function, think it's fine. included have entire file (this isn't main btw.)

other notes: -the systemcommands array supposed of command pointers of length number_of_commands (i think did right)

-the fillsystemcommandlist function supposed populate systemcommands array structures contain pointers command strings , corresponding defined constants.

-i know code c, , that's again because class i'm taking beginning c++ class.

#include "system_utilities.h" #include "definitions.h" using namespace std;   int getcommandnumber(char *s);  class command {     char* pointertochar;     int* pointertoint;   public:     command(char*, int);     int amithiscommand(char*); };  int command::amithiscommand(char* command){     return 0; }  command* systemcommands[number_of_commands];    int parsecommandline(char cline[], char *tklist[]){     int i;     int length; //length of line     int count = 0; //counts number of tokens     int toklength = 0; //counts length of each token     length = strlen(cline);     (i=0; < length; i++) {   //go first character of each token          if (((cline[i] != ' ' && cline[i-1]==' ') || == 0)&& cline[i]!= '"') {                while ((cline[i]!=' ')&& (cline[i] != '\0') && (cline[i] != '\r')){                 toklength++;                 i++;             }           //---------------         tklist[count] = (char *) malloc( toklength +1);         memcpy(tklist[count], &cline[i-toklength], toklength);         tklist[count][toklength]='\0';             //cout << "\n" << tklist[count] << "\n";             //cout << "\n" << << "\n";             //cout << "\n" << toklength << "\n";         //--------------             count ++;             toklength = 0;         }          if (cline[i] == '"') {             {                 toklength++;                 i++;                 /*if (cline[i] == ' ') {                     toklength--;                 }*/             } while (cline[i]!='"');              //--------------             tklist[count] = (char *) malloc( toklength +1);             memcpy(tklist[count], &cline[i-toklength+1], toklength-1);             tklist[count][toklength]='\0';             //cout << "\n" << tklist[count] << "\n";             //cout << "\n" << << "\n";             //cout << "\n" << toklength << "\n";              //--------------             count ++;             toklength = 0;         }      }      return count;    }  int getcommandnumber(char *s) {      /*switch (*s) {        // case "halt":             return halt;             break;          default:             break;     }*/     return 0;  }  void fillsystemcommandlist() {      systemcommands[0] = new command("halt", halt);     systemcommands[1] = new command("status", status);     systemcommands[2] = new command("time_click", time_click);     systemcommands[3] = new command("new_sensor", new_sensor);     systemcommands[4] = new command("new_sensor_node", new_sensor_node);     systemcommands[5] = new command("new_network", new_network);     systemcommands[6] = new command("add_sensor_to_node", add_sensor_to_node);     systemcommands[7] = new command("add_node_to_network", add_node_to_network);     systemcommands[8] = new command("sensor_command", sensor_command);  } 

thanks again can give!

systemcommands class of command objects. command class has member char* type, however: "halt" in

   systemcommands[0] = new command("halt", halt); 

are of const char*, therefore got warning message. did not define constructor of command class.

  command(const char*, int); //needs defined. note ptr const 

therefore, got error when do:

  systemcommands[0] = new command("halt", halt); 

which tries call constructor prototype: command(char*, int);.


Comments

Popular posts from this blog

SPSS keyboard combination alters encoding -

Add new record to the table by click on the button in Microsoft Access -

javascript - jQuery .height() return 0 when visible but non-0 when hidden -