pure-virtual Questions
4
Solved
The benefit of defining common virtual functions in the base class is that we don't have to redefine them in the derived classes then.
Even if we define pure virtual functions in the base class i...
Pinup asked 9/11, 2011 at 10:56
4
Solved
I would have thought lots of people would have wondered whether this is possible but I can't find any duplicate questions... do correct me.
I just want to know whether PHP offers pure virtual func...
Hideaway asked 29/9, 2011 at 17:0
6
Solved
I am working on an exercise which asks me to take a base class Rodent and make it a pure abstract class. My understanding of a pure abstract class is that it acts as an interface and only contains ...
Dhiman asked 28/9, 2011 at 15:49
2
Solved
Error is here:
vector<Graduate *> graduates;
graduates.push_back(new AliceUniversity(identifier,id,salary,average));
Grandparent class:
Graduate::Graduate(char identifier,
long id,
int ...
Radioscopy asked 8/9, 2011 at 18:23
6
Solved
Consider the following :
class Abstract
{
public:
virtual void func() = 0;
};
int main() {
Abstract abs1; // doesn't compile
Abstract * abs2 = new Abstract(); // doesn't compile
Abstract * ...
Tradeswoman asked 1/9, 2011 at 10:42
4
So here is the box I am in. I want to understand why it is important to have a "virtual destructor inside your interface class". You will see why that stuff is in quotes if you can hang to the end....
Superheterodyne asked 6/8, 2011 at 13:9
4
Solved
Possible Duplicates:
Under what circumstances is it advantageous to give an implementation of a pure virtual function?
Why do we need a pure virtual destructor in C++?
Compiler doesn...
Whereof asked 28/7, 2011 at 9:25
10
I have found some code that I am working on, and was wondering what the best design implementation is.
If a base class defines a method as virtual, but implements an empty body as well, thus not r...
Vinosity asked 27/7, 2011 at 11:3
2
Solved
Can I change a pure-virtual function (in a base class) to become non-pure without running into any binary compatibility issues? (Linux, GCC 4.1)
thanks
Sawmill asked 19/7, 2011 at 14:33
7
Solved
EDIT: SOLVED
I'm working on a multi-threaded project right now where I have a base worker class, with varying worker classes that inherit from it. At runtime, the worker classes become threads, wh...
Catto asked 30/1, 2010 at 8:53
3
Solved
I was browsing through the sources of a (prefer not to name) GUI Toolkit which wrapped up the Windows API when I found the following function definition in the window class:
virtual LRESULT CALLB...
Sirotek asked 9/7, 2011 at 11:8
3
Solved
Consider this demo program:
#include <stdio.h>
class Base
{
public:
virtual int f(int) =0;
virtual int f(){ return f(0); }
virtual ~Base(){ }
};
class Derived : public Base
{
public:
...
Escalera asked 3/6, 2011 at 22:0
2
Solved
I'm using boost.python to make python-modules written in c++. I have some base class with pure virtual functions which I have exported like this:
class Base
{
virtual int getPosition() = 0;
};
b...
Sweltering asked 16/4, 2011 at 17:30
3
Solved
Pure virtual functions (when we set = 0) can also have a function body.
What is the use to provide a function body for pure virtual functions, if they are not going to be called at all?
Ebracteate asked 30/3, 2011 at 4:45
3
Solved
According to my (limited) knowledge of the C++ spec, the vtable of a class with virtual members is placed at the definition of the first non-pure non-inline virtual method. How do compilers handle ...
Rivera asked 6/1, 2011 at 18:5
5
Solved
C++03 3.2.2 ...An object or non-overloaded function is used if its name appears in a potentially-evaluated expression. A virtual member function is used if it is not pure...
And then later in 3.2....
Ferromagnetic asked 10/11, 2010 at 15:15
5
Solved
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"; }
};
t...
Fumble asked 23/7, 2010 at 16:20
3
Solved
why if we have pure virtual assignment operator in a base class, then we implement that operator on the derived class, it give linker error on the base class?
currently I only have the following e...
Tattered asked 21/9, 2010 at 13:54
4
Solved
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 ...
Coexist asked 17/8, 2010 at 13:45
1
Solved
Say we have a class inheriting from two base classes (multiple inheritance). Base class A is abstract, declaring a pure virtual function foo, the other base class B declares and implements a functi...
Calvaria asked 20/7, 2010 at 15:22
2
Solved
I have a small wrapper which centralize what's relative to threads :
class Thread {
protected:
boost::thread *m_thread;
virtual void work() = 0;
void do_work() {
work();
}
public:
Thread(...
Mattock asked 1/7, 2010 at 17:59
2
Solved
I recently switched back from Java and Ruby to C++, and much to my surprise I have to recompile files that use the public interface when I change the method signature of a private method, because a...
Fallingout asked 22/6, 2010 at 11:2
4
Solved
What is the difference between a pure virtual function and a virtual function?
I know "Pure Virtual Function is a Virtual function with no body", but what does this mean and what is actuall...
Dysthymia asked 16/4, 2010 at 10:33
11
Solved
We always declare a pure virtual function as:
virtual void fun () = 0 ;
I.e., it is always assigned to 0.
What I understand is that this is to initialize the vtable entry for this function to N...
Trug asked 28/1, 2010 at 17:48
3
Solved
I understand why calling a virtual function from a constructor is bad, but I'm not sure why defining a destructor would result in a "pure virtual method called" exception. The code uses const value...
Phosphorate asked 1/1, 2010 at 0:47
© 2022 - 2024 — McMap. All rights reserved.