none
ref class inheriting another class RRS feed

  • Question

  • What I want to do is create my own class that inherits all the properties and methods of the TcpListener class from System::Net::Sockets and add my own custom methods and properties to that.  Here is my code:

    ref class Tcp : TcpListener
    {
    public:
        Tcp(void)
        {
        }
    };

    The problem is that I get the following error:
    Error    1    error C2512: 'System::Net::Sockets::TcpListener::TcpListener' : no appropriate default constructor available    c:\Documents and Settings\Dave S. Anderson\My Documents\Visual Studio 2005\Projects\tcp\tcp\tcp.cpp    16   

    Any help is appreciated.

    *note:  I need this to be managed code, I can't use native.  This is strictly a C++/CLR application I am creating.
    Monday, January 8, 2007 11:59 PM

Answers

  • I fixed my problem. Here is my solution:

    ref class Tcp : TcpListener
    {
    public:
        Tcp(void) : TcpListener(nullptr)
        {
        }
    };

    Tuesday, January 9, 2007 12:58 AM