pure-virtual Questions
4
Solved
The GCC C++ compiler offers a family of extensions via function attributes, such as:
int square(int) __attribute__((const));
Two attributes in particular, const and pure, allow you to declare th...
Jackinthepulpit asked 12/6, 2012 at 9:41
4
So I have an abstract base class with no abstract methods. In order to enforce abstractness, I've declared the (non-trivial) destructor as pure virtual:
class AbstractClass
{
public:
AbstractClas...
Sisak asked 26/9, 2012 at 0:12
3
Solved
I have a project for school in C++ and I am stuck on one part:
I have to overload the operators + and * to work with geometrical figures. That was no problem, but here it where it doesn’t work: I ...
Babism asked 22/5, 2013 at 10:42
6
Solved
I want to go to there. Seriously though, how does one implement a pure virtual method in an "Apple" way? Do you use a Protocol with your base class and throw exceptions on those methods?
Devastate asked 7/3, 2011 at 16:19
2
Solved
Here is the problem: I keep getting the unimplemented pure virtual method error when trying to compile. I have implemented all of the pure virtual methods in the abstract base class. Any ideas?
he...
Hothouse asked 3/4, 2013 at 0:51
2
Solved
Not a Duplicate of Invoking virtual function and pure-virtual function from a constructor:
Former Question relates to C++ 03, not new Constructor Delegation behavior in C++ 11, and the question do...
Lynsey asked 4/2, 2013 at 6:18
6
Solved
As I understand temporaries, the following code should work, but it doesn't.
struct base
{
virtual~base() {}
virtual void virt()const=0;
};
struct derived:public base
{
virtual void virt()const...
Herbage asked 23/1, 2013 at 22:50
2
Solved
I can understand that there might be a reason to declare an implemented (as opposed to pure) virtual function private or protected. Afaik, if you declare an implemented virtual method as protected,...
Papacy asked 19/3, 2012 at 1:57
5
Solved
Pure virtual functions are those member functions that are virtual and have the pure-specifier ( = 0; )
Clause 10.4 paragraph 2 of C++03 tells us what an abstract class is and, as a side note, the...
Homocyclic asked 13/11, 2010 at 21:8
3
Solved
class Foo
{
public:
virtual int foo() final = 0;
};
Compiles fine.
Isn't Foo just a waste of space, and an accident in the making? Or am I missing something?
Beloved asked 14/12, 2012 at 14:35
3
I'm trying to create a counter interface that forces all derived classes to implement this interface:
class CounterInterface
{
public:
virtual CounterInterface& operator ++ () = 0;
virtual...
Prurigo asked 14/12, 2012 at 12:11
4
Solved
Suppose I have the following code:
class Iinterface
{
virtual void abstractFunction()=0;
};
class Derived : public Iinterface
{
void abstractFunction(); // Do I need this line?
};
Derived::ab...
Galaxy asked 19/11, 2012 at 6:59
2
Solved
I have a class Base with a pure virtual function f(). Another class Derived derives from Base. I call f() from within Derived. And using g++, I get an error from the linker.
[agnel@dooku tmp]$ g++...
Carditis asked 27/9, 2012 at 17:12
2
Solved
EDIT: After spending a bit of time understanding the code I wrote I still don't know what is wrong with it. This is the base class from which I derived my class:
///ContactResultCallback is used t...
Decorate asked 25/7, 2012 at 0:5
3
I often use pure virtual classes (interfaces) to reduce dependencies between implementations of different classes in my current project. It is not unusual for me to even have hierarchies in which I...
Inarch asked 3/3, 2012 at 21:46
2
shared_ptr<Shape> circle(new Circle(Vec2f(0, 0), 0.1, Vec3f(1, 0, 0)));
shared_ptr<Shape> rect(new Rect2f(Vec2f(0, 0), 5.0f, 5.0f, 0,
Vec3f(1.0f, 1.0f, 0)) );
I'm trying to understa...
Hereabouts asked 13/1, 2012 at 2:18
2
Solved
Possible Duplicate:
Calling virtual functions inside constructors
Look at this code.
In the constructor of Base class, we can call the pure virtual function using 'this' pointer. Now ...
Selfpollination asked 2/3, 2012 at 6:36
6
Solved
First of all, I searched this problem and found a lot of similiar questions, but I couldn't find an answer that fixed my problem. I am very sorry if that is just me being dumb.
What I am trying to...
Ecru asked 27/2, 2012 at 23:12
2
Solved
I'm trying to set up a syntactical sugar similar to the c# property concept.
I've read this post: C#-like properties in native c++?. It's helpful, but lacks the design I want. I also respectfully d...
Superabound asked 18/2, 2012 at 23:46
3
Solved
I have a purely virtual class defined as such:
class BaseClass {
protected:
const int var;
public:
void somefun() = 0; // what I mean by a purely virtual class
// stuff...
};
If I don't add...
Serviceman asked 22/2, 2012 at 16:55
6
Solved
Consider the following sample code:
#include <iostream>
using namespace std;
class base
{
public:
base()
{
bar(); //Line1
this->bar(); //Line2
base *bptr = this;
bptr->bar();...
Logue asked 9/2, 2012 at 14:1
4
Solved
From 10.4 Abstract Classes parag. 6 in the Standard :
"Member functions can be called from a constructor (or destructor) of an abstract class; the effect of making a virtual call to a pure virtual...
Baird asked 8/2, 2012 at 0:3
2
Solved
I've found a strange behavior while using a reference variable.
Here is class implementations:
class Base {
public:
virtual void Method() = 0;
};
class DerivedA : public Base {
public:
virtu...
Mentalism asked 3/12, 2011 at 10:39
5
Solved
The pure virtual destructor in base class should have a definition. Otherwise compiler will generate a call to base class destructor from the derived class destructor during link-time and will caus...
Yaroslavl asked 19/11, 2011 at 14:11
5
Solved
Edit: Per some comments, by simple I mean a) less code, b) easy to maintain, and c) hard to get wrong.
Edit #2: Also, using containment instead of private inheritance is not objectionable if it do...
Sufficient asked 12/11, 2011 at 15:32
© 2022 - 2024 — McMap. All rights reserved.