pure-virtual Questions
1
Solved
How to implement in the following code the abstract base class in a generic case. The code is simplified from a library I am working on. So an explicit implementation for int and double is not an o...
Nicodemus asked 8/10, 2016 at 23:2
3
Regarding this post:
For implementations that use vtable, the answer is: Yes, usually. You
might think that vtable isn't required for abstract classes because
the derived class will have its o...
Hypha asked 8/9, 2016 at 10:58
2
I am having a bit of a struggle with Microsoft Visual C++ 2015 and was able to replicate the issue with a small program. Given the following classes:
class BaseClass {
public:
BaseClass()
: mVal...
Leonie asked 1/8, 2016 at 16:49
3
Solved
UPD. There is a mark that it is a duplicate of this question. But in that question OP asks HOW to use default to define pure virtual destructor. This question is about what the difference.
In C++ ...
Pachston asked 12/6, 2016 at 18:19
1
Solved
The following code compiles on a wide range of gcc and clang versions - when compiled and run with gcc 5.3.1, it prints
A()
then aborts with a pure virtual call error.
#include <stdio.h&g...
Peachy asked 4/5, 2016 at 1:46
7
Solved
I've been told to make my class abstract:
public abstract class Airplane_Abstract
And to make a method called move virtual
public virtual void Move()
{
//use the property to ensure that the...
Halve asked 9/2, 2011 at 18:35
2
Solved
I have three classes: B, D and G. D is a B and G is a D. Both B and D are abstract. B is from a third party.
B has a non-pure, virtual method that G needs to implement (to be a D). Can I and is it...
Preparedness asked 4/11, 2015 at 16:12
2
Solved
I tried to "repair" the example in this answer as to demonstrate how a pure virtual function can be called.
#include <iostream>
using namespace std;
class A
{
int id;
public:
A(int i): i...
Roby asked 11/6, 2015 at 11:59
2
Solved
Consider the following 2 programs.
#include <iostream>
using std::cout;
class Base {
public:
virtual void f()=0;
void g() {
f();
}
virtual ~Base() { }
};
class Derived : public Base
{
...
Carbylamine asked 23/5, 2015 at 17:31
6
Solved
Today i was reading about pure function, got confused with its use:
A function is said to be pure if it returns same set of values for same set of inputs and does not have any observable side eff...
Kathrynekathy asked 22/6, 2012 at 9:42
6
Solved
I usually use pure virtual functions for those methods that are required by my code to work well. Therefore, I create interfaces and then other users implement their derived classes. The derived cl...
Kreager asked 5/4, 2013 at 6:52
6
Solved
While compiling on GCC I get the error: pure-specifier on function-definition, but not when I compile the same code using VS2005.
class Dummy {
//error: pure-specifier on function-definition, VS...
Ulland asked 1/6, 2010 at 15:56
2
Solved
Does it ever make sense to override a pure virtual method with another pure virtual method? Are there any functional differences or perhaps code style reasons to prefer one of the following options...
Hoe asked 17/4, 2015 at 19:51
2
Solved
I may be coming from a different mindset, being primarily a C++ programmer. This question has to do with OOP in Python and more specifically pure virtual methods. So taking code I adapted from this...
Ejecta asked 20/10, 2014 at 4:32
3
Solved
So, based on a cursory search, I already know that calling a virtual function (pure or otherwise) from a constructor is a no go. I have restructured my code to ensure that I am not doing that. Whil...
Thicken asked 2/7, 2013 at 1:32
5
Solved
The following example is from the book "Inside C++ object model"
class Abstract_base {
public:
virtual ~Abstract_base () = 0;
virtual void interface () const = 0;
virtual const char* m...
Marcy asked 4/6, 2014 at 12:7
3
Solved
Possibly I just missed something from the documentation (or just can't do a proper Google serach), but I have issues with a shared_ptr and pure virtual functions.
So a short example which works:
...
Writeoff asked 11/4, 2014 at 12:30
4
Solved
Do C++ compilers generate the default functions like Constructor/Destructor/Copy-Constructor... for this "class"?
class IMyInterface
{
virtual void MyInterfaceFunction() = 0;
}
I mean it is not...
Gypsy asked 23/1, 2014 at 11:33
4
I'm sure we've all seen code that crashes due to a bug that results in a pure virtual function being called. One simple example is like this:
struct Base
{
Base() { method(); }
virtual void met...
Roter asked 6/2, 2014 at 10:7
2
I declare some class with pure virtual methods and make some classes derive it. Is there any way in Eclipse CDT to locate the pure virtual functions of the parent class and auto complete the declar...
Silicone asked 28/1, 2012 at 20:5
8
Solved
In C++98, the null pointer was represented by the literal 0 (or in fact any constant expression whose value was zero). In C++11, we prefer nullptr instead. But this doesn't work for pure virtual fu...
Agonist asked 31/12, 2013 at 17:51
3
Solved
Consider following example
#include <iostream>
struct PureVirtual {
virtual void Function() = 0;
};
struct FunctionImpl {
virtual void Function() {
std::cout << "FunctionImpl:...
Topgallant asked 12/12, 2013 at 16:8
3
Solved
The question's title is pretty clear. Here's what I mean by example:
class A
{
public:
virtual void f() = 0;
};
class B: public A
{
public:
virtual void f() = 0;
};
class C: public B
{
public:...
Prince asked 22/11, 2013 at 12:31
1
Solved
Consider an example where a method is pure virtual, takes a parameter of a templated type (injected from an outer type), and that templated type is a local type (defined in a function body). This s...
Shading asked 24/9, 2013 at 23:56
3
In C++11 we are guided in some cases to pass objects by value and in others by const-reference. However, this guideline depends on the implementation of the method, not just on its interface and in...
Plagio asked 3/9, 2013 at 14:40
© 2022 - 2024 — McMap. All rights reserved.