Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

C++ abstract bullshite

Name: melting void 2011-12-16 0:05

I have an abstract class (it has 1 member, which is a pure virtual function) which we'll call R, and I want a member function of some other class to take as an argument a reference to any class that inherits from R.

How should I declare this member function?

Name: Anonymous 2011-12-16 12:59

>>5
That's what I was trying, but it gives me an error.

class R {
        public:
        virtual void poo() = 0;
};

class P : public R {
        public:
        void poo() { cout << "Hello" << endl; }
};

class T {
        public:
        T(P& p);
};

int main() {
        T myt = new T(new P());
}


no matching function for call to `T::T(P*)'
candidates are: T::T(const T&)
                T::T(R&)

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List