problem when trying to inherit from EthernetClient class


hello,

i'm trying create new class inherits ethernetclient class, in order add specific functions parse http commands needs. , can't manage have working.

initially, had code such as:

code: [select]
void loop() {
  ethernetclient client = server.available();

  if (client) {
     get_http_request(client);

     ....
  }
}


now, make get_http_request() function method of new class inherit ethernetclient, like:

code: [select]
class myethernetclient : public ethernetclient {
public:
    string gethttprequest();
};

myethernetclient::gethttprequest() {
...}


and above code become somthing like:

code: [select]
void loop() {
  myethernetclient client = server.available();

  if (client) {
     cmdstring = client.gethttprequest();
     ....
  }
}


but when doing this, following compilation error:
quote
error: conversion 'ethernetclient' non-scalar type 'myethernetclient' requested


so then, tried do:
code: [select]
myethernetclient client = (myethernetclient) server.available();

this time got following compilation error:
quote
error: no matching function call myethernetclient::myethernetclient(ethernetclient)


so then, tried add constructor in new class:
code: [select]
class myethernetclient : public ethernetclient {
public:
    myethernetclient (ethernetclient client) : ethernetclient() {};
    string gethttprequest();
};


this time, got no compilation error, doesn't work before, "if (client) {" of loop function never succeeds.

could explain me problem in way try extend base class?

thanks , regards,
michael

... , sorry long message way. :)


Arduino Forum > Using Arduino > Programming Questions > problem when trying to inherit from EthernetClient class


arduino

Comments

Popular posts from this blog

opencv3, tbb and rasp pi 2 - Raspberry Pi Forums

small ethernet problem - Raspberry Pi Forums

Multithumb configuration params not working? - Joomla! Forum - community, help and support