pure-virtual

C++ template duck-typing vs pure virtual base class inheritance

Which are the guidelines for choosing between template duck-typing and pure virtual base class inheritance? Examples: // templates class duck { void sing() { std::cout << "quack\n"; } }; template<typename bird> void somefunc(const bird& b) { b.sing(); } // pure virtual base class class bird { virtual void sing() = 0; }; c...

C++ Forward declaration and pure virtual functions

Hi, I have a problem using forward declaration and virtual functions. I got the following error message during compilation. main.cpp:131: error: cannot allocate an object of abstract type ‘Database::MySQL’ database_mysql.h:31: note: because the following virtual functions are pure within ‘Database::MySQL’: database.h:28: note: vir...

Should an abstract class' destructor be pure virtual?

I think virtual alone is generally sufficient. Is there another reason to make it pure virtual than to force derived classes to implement their own destructor? I mean if you allocate something in your class' constructor you should impement your own destructor - if your class is derived or not. Doesn't count as answer as I already know:...

C++ - calling derived function from abstract base pointer

Hello, I have been trying to create a TCP Server model based on inheritance, with varying success. These servers are managed by a singleton whose task it is to shut these servers down and other simple maintenance functions: class TCPServer { public: TCPServer(); ~TCPServer(); void Bind(TCPDaemon *daemon) { if(!daemo...

What does this line mean?

Possible Duplicates: C++ Virtual/Pure Virtual Explained What's the difference between virtual function instantiations in c++ Why pure virtual function is initialized by 0? This is a method in some class declaration that someone gave me. And I don't know what '..=0' means. What is it? virtual void Print() const = 0; ...

Redefinition of pure virtual methods in C++

Do you have to declare methods replacing a pure virtual function in a base class? If so, why? Because the base class has declared the methods as pure virtual, and therefore MUST exist in derived class, then is should not be necessary to redeclare them in the derived class before you can implement them outside of the class definition. Wou...

How to export pure virtual functions from a DLL in C++?

Hello, I am having a strange problem that no pure virtual function is exporting from a DLL. DLL compiles and outputs as .dll file to the directory . But it doesn't produce .lib file. If I give definition and it no longer remians as pure virtual, after that happily it creates .lib file. I need to implement factory pattern for which I n...