This is pretty new to me, so bear with me. I am having trouble creating a EthernetServer class instance inside my c++ library class. When I try to compile(below), IDE is telling me that it has no matching function for 'EthernetServer::EthernetServer()' + all the derivatives. I think it is telling that I have to implement the methods of ethernetserver. I don't want to do that. Just want to use it in my class like-> aserver.begin()..etc. Can anybody offer some assistance or guidance on how to learn about this?
Thanks,
-ren
#include <EthernetClient.h> #include <EthernetServer.h>
class myserver: public print
{
public:
.....
private:
EthernetServer aserver;
I understand, makes sense. I would need to initialize an instance of this class with its constructor. If ethernetserver class does not have a default w/o variable, then I need to use another one of the constructors. However, the code I was referencing uses this same techique, why does it compile successfully? Ref. https://github.com/sirleech/Webduino/blob/master/WebServer.h, excerpt below.
Look further down. Their constructor initializes the embedded class with an initialization list. This is permitted (one constructor initializes another constructor):
WebServer::WebServer(const char *urlPrefix, int port) :
m_server(port), // <------------ here
m_client(255),
m_urlPrefix(urlPrefix),
m_pushbackDepth(0),
m_cmdCount(0),
m_contentLength(0),
m_failureCmd(&defaultFailCmd),
m_defaultCmd(&defaultFailCmd)
{
}