I've following situation

class base
{
public:

   virtual void Accepted(SOCKET s)  //// Event
   {

   }
   void Listner()
   {
          SOCKET acpted;
          Accepted(acpted); /// When I call I want derived class's Accepted() to get called

   }

};


class derived
{
   virtual void Accepted(SOCKET s)  //// Event
   {
         ////// HERE i will write actual implementation (QUESTION)
   }

}

I wish to call derived class's function. This works like event here. I wish to inform derived class that something happened in base class.

class derived : public base can make derived really inherit from base. Your virtual function call will act as expected.

Observe that you can't make such virtual function calls within the constructor or destructor of base - At that time base's constructor is invoked, the derived part does not yet exist. At that time base destructor is invoked, the derived part was already destructed.

EDIT: Demo, in reaction to comment.

class base
{
public:
    virtual void Accepted(SOCKET s)  //// Event
    {
        cout << "base::Accepted" << endl;
    }
    void Listner()
    {
        SOCKET acpted = 0;
        Accepted(acpted); /// When I call I want derived class's Accepted() to get called
    }
};


class derived : public base
{
    virtual void Accepted(SOCKET s)  //// Event
    {
        cout << "derived::Accepted" << endl;
    }
};


int main(int argc, char * argv[])
{
  derived d;
    d.Listner();
}

This can print derived::Accepted

This works how you want. In case your actual code is not working, then you definitely havent proven us everything relevant. For this reason we implore you to definitely show us real code. Would you suppose you are the only person here that's handling a large codebase that can't be shared on the web? How can you think the relaxation people get help? Write a little example that really illegal copies the behaviour you are seeing and publish that. Don't publish psudocode you have not even put together.

This is how that you can do what you are attempting to do, as well as a good example of how you ought to be posting.

#include <iostream>
using namespace std;

class Base
{
public:
    virtual void Accepted()
    {
        cout << "Base::Accepted" << endl;
    }
    void Listener()
    {
        cout << "Base::Listener" << endl;
        Accepted();
    }
};

class Der : public Base
{
public:
    void Accepted()
    {
        cout << "Derived::Accepted" << endl;
    }
};

int main()
{
    cout << "*** BASE ***" << endl;
    Base b;
    b.Listener();

    cout << "\n*** DERIVED ***" << endl;
    Der d;
    d.Listener();
}

Output is:

*** BASE ***
Base::Listener
Base::Accepted

*** DERIVED ***
Base::Listener
Derived::Accepted

Additionally to create p derived class stretching the bottom class (derived : public base) you might declare you Recognized method pure virtual within the base class:

virtual void Accepted(SOCKET s) = 0;

by doing this the derived class needs to implement the recognized method.

As well as the Recognized method within the derived class does not have to be virtual.

Make following changes inside your code. 1) class derived : public base 2) Create object of derived class and call Listener function. (If you're creating object of base class, it won't work)

Dhiraj

Take care not to call your virtual functions throughout construction or destruction. Bad implementation defined things sometimes happens:

C++ virtual function from constructor