One for the Arduino C++ class experts...

I want to create a base class to upload data to webservices, and then several child classes which inherit from the base.

Ideally I'd like to override a method/property of the base class to hold the URL as a PROGMEM string.  I intend to use EtherCard library so want to get the url into the dnslookup so needs to be a PROGMEM CHAR* type.

Consider the following code sample which shows what the problem is!

I think its a pointer thing as usual in C. 

 


class WebSiteService
{ 
private: 
  uint8_t hostip[4];

public:
  virtual prog_char* getWebAddress();
  void doSomeWork();
};

void WebSiteService::doSomeWork() {
  Serial.println("WebSiteService::doSomeWork");

  Serial.println(this-> getWebAddress());
}


class childClass :
public WebSiteService
{
public:
  virtual prog_char* getWebAddress();
};

prog_char* childClass::getWebAddress() {
  Serial.println("childClass::getWebAddress");

  char url[] PROGMEM = "www.google.com";
  return url;
}

void setup(){
  Serial.begin(115200);          //Serial port for debugging output
  Serial.println("setup");
}

void loop()
{
  Serial.println("loop");

  childClass myobject;

  myobject.doSomeWork();


  while (1) {
    delay(5000);
  }
}