C++ pure virtual function call ... Some pattern for this situation?

205 views Asked by At

I found this problem. In the folowing code I am unable to create object Mother, I get "R6025 - pure virtual function call" error. When class Parent is not abstract, everythig is OK. Is there some pattern to have class Parent abstract and not get this error ?

    ref class Parent;
    ref class Child
    {
    internal:
        Child(Parent^ r)
        {
            parent = WeakReference(r); // ERROR R6025 - pure virtual function call
        }
    private:
        WeakReference parent;
    };

    ref class Parent abstract
    {
    internal:
        Parent()
        {
            child = ref new Child(this);
        }

        Child^ child;

        virtual void DoSomething() = 0;
    };
    ref class Mother : Parent
    {
    internal:
        Mother() :
            Parent()
        {
        }

        virtual void DoSomething()  override
        {
        }
    };
0

There are 0 answers