I have a class which includes among its members an object of another class.
The header file looks like this:
class LinxArduinoEthernetListener : public LinxListener
{
EthernetServer ArduinoTcpServer(uint16_t);
Where EthernetServer is itself a class (defined in the Arduino EthernetServer.h library).
Because I do not know the port at compile time, but the server object should be a member of the listener class, I allow the server object to be initialized in the class constructor, and then attempt to reassign that object later, using the following code (in the corresponding .cpp file):
ArduinoTcpServer = EthernetServer(port);
Where "port" is a uint16_t. As far as I know, this is the correct way to reassign to an object variable a newly constructed instance.
And yet, the compiler gives me the following error:
LinxArduinoEthernetListener.cpp:122: error: invalid use of member function (did you forget the '()' ?)
ArduinoTcpServer = EthernetServer((uint16_t)port);
I think this may be related to the error I get for the immediately subsequent function call:
LinxArduinoEthernetListener.cpp:123: error: '((LinxArduinoEthernetListener*)this)->LinxArduinoEthernetListener::ArduinoTcpServer' does not have class type
ArduinoTcpServer.begin();
But I would say it clearly does have a class type, namely the EthernetServer class, as specified in the header file.
What am I doing wrong here?