pure-virtual Questions

3

Solved

Whilst compiling with avr-gcc I have encountered linker errors such as the following: undefined reference to `__cxa_pure_virtual' I've found this document which states: The __cxa_pure_virtual fun...
Behold asked 28/5, 2009 at 11:55

6

Nearly the final step but still some strange erros.... bash-3.2$ make g++ -Wall -c -g Myworld.cc g++ -Wall -g solvePlanningProblem.o Position.o AStarNode.o PRM.o PRMNode.o World.o SingleCircleWorl...

6

Solved

As it is explained in The C++ programming language: virtual void push(char c) = 0; virtual void pop() = 0; The word virtual means 'may be redefined later in a class derived from this one' The =0...
Shotputter asked 2/9, 2016 at 9:21

4

Solved

I teach a C++ programming class and I've seen enough classes of errors that I have a good feeling for how to diagnose common C++ bugs. However, there's one major type of error for which my intuitio...
Trave asked 6/1, 2011 at 7:19

3

Solved

I'm having some trouble implementing pure virtual functions inherited from some abstract class, when the classes in question are divided into *.h and *.cpp files. The compiler (g++) tells me that t...
Crutchfield asked 13/1, 2011 at 0:29

10

Solved

My basic understanding is that there is no implementation for a pure virtual function, however, I was told there might be implementation for pure virtual function. class A { public: virtual void...
Smaze asked 18/1, 2010 at 20:45

4

Solved

I understand why I am getting the error I am getting (pure virtual function called). I am trying to call pure virtual functions from within the destructor of my base class shown below. However, I d...
Pears asked 27/1, 2013 at 16:34

6

Solved

The C++ standard says that invoking a pure virtual function from a constructor or destructor is forbidden. What is the reason for this? Why should the standard place a restriction like this?
Tolkan asked 28/12, 2011 at 4:36

17

Solved

How do I setup a class that represents an interface? Is this just an abstract base class?
Rosewater asked 25/11, 2008 at 16:48

1

Solved

Let's say I have a base class called Human. Baby and Adult are sub-classes of Human. Human has a function run as a pure virtual function and I don't want Baby to inherit run but if I don't override...
Pablo asked 15/1, 2021 at 6:10

3

Solved

I understand why this is happening, but I'm stuck trying to resolve it...here is what my code is doing when the error is generated (thus, leading to a crash) when my program exits... pure virtual ...
Alleviate asked 22/5, 2012 at 17:49

1

Solved

I have an adapter class which handles classes of the same concept. Now, I want that adapter, based on template parameter RO (read only) to disable pack(). But I don't know if that is not supported ...
Paranoid asked 26/7, 2020 at 19:49

4

Solved

I know the cases where pure virtual destructors are needed. I also know that If we don't provide an implementation for them it will give me a linker error. What I don't understand is why this shoul...
Retha asked 14/1, 2014 at 9:0

8

Solved

I have a base class MyBase that contains a pure virtual function: void PrintStartMessage() = 0 I want each derived class to call it in their constructor then I put it in base class(MyBase) cons...

1

Solved

Note: I do not ask whether or not this is reasonable thing to do or if this is good design. I'm just asking if this is well-defined behaviour and if the results are as expected. I came upon ...
Kerley asked 5/3, 2020 at 10:43

3

Solved

I have a base class class ShapeF { public: ShapeF(); virtual ~ShapeF(); inline void SetPosition(const Vector2& inPosition) { mPosition.Set(inPosition); } protected: Vector2 mPosition; } ...
Suttle asked 31/1, 2013 at 17:32

8

Solved

I sometimes notice programs that crash on my computer with the error: "pure virtual function call". How do these programs even compile when an object cannot be created of an abstract class?
Hartley asked 19/9, 2008 at 4:9

2

Solved

In Nicola Gigante's lecture in 2015, he mentions (at the beginning) that there are no pure virtual functions in the Standard Library (or he's not aware of any). I believe that Alex Stepanov was aga...
Yardman asked 26/1, 2016 at 23:38

1

Solved

I am a student learning C++. I am creating a UML class diagram for my program that involves inheritance and abstract / concrete classes, but I'm not too sure how I would denote a pure virtual funct...
Quartz asked 12/11, 2018 at 21:44

11

Solved

I understand the need for a virtual destructor. But why do we need a pure virtual destructor? In one of the C++ articles, the author has mentioned that we use pure virtual destructor when we want t...
Crutchfield asked 2/8, 2009 at 19:27

4

Solved

For example: class Base { virtual void my_function() = 0; }; class Derived : Base { void my_function() override; }; From what I read, the override keyword is used to make sure that we have th...
Don asked 27/9, 2017 at 11:22

4

Solved

Consider the following standard CRTP example: #include <iostream> template<class Derived> struct Base { void f() { static_cast<Derived *>(this)->f(); } void g() { static_ca...
Ardelia asked 18/7, 2017 at 9:50

2

Solved

Let us suppose that we have an abstract class NonEditableSuperBase from which we create another abstract class MyBase. The first class NonEditableSuperBase has a virtual function (non pure virtual...
Callisthenics asked 31/3, 2017 at 14:55

1

Solved

I have a set of classes that implement the same business methods. I plan to use CRTP instead of virtual dispatch due to performance reasons. But I'd like to keep the convenience of coding to a sing...
Klan asked 1/12, 2016 at 11:48

1

Solved

Can anyone help explain this unexpected behavior? The Premise I've created class Thread that contains a member std::thread variable. Thread's ctor constructs the member std::thread providing a po...
Shuddering asked 29/10, 2016 at 9:1

© 2022 - 2024 — McMap. All rights reserved.