642 questions
- Bountied 0
- Unanswered
- Frequent
- Score
- Trending
- Week
- Month
- Unanswered (my tags)
0
votes
0
answers
55
views
Why the destructor pointer is null in construction vtable?
My code is below:
class GrandParent {
public:
GrandParent() {}
virtual ~GrandParent() {}
int grandparent_data = 100;
};
class Parent1 : virtual public GrandParent {
public:
Parent1() {}...
15
votes
2
answers
811
views
MSVC calls wrong virtual method when storing a pointer to virtual method in a static inline variable
I'm encountering unexpected behavior on MSVC when storing a pointer to a virtual method in a static inline variable. The issue does not occur on GCC or Clang.
Specifically, when I store a pointer to a ...
2
votes
0
answers
142
views
Eliminate unused virtual functions in Base class?
If a derived class Sub overrides a virtual method foo from the base class, and there is no chance to invoke it during the brief phases of construction/destruction when the type of the partially ...
0
votes
0
answers
64
views
boost::system::error_code::message() crashed, for it call __cxxabiv1::__cxa_pure_virtual() actually
boost:Version 1.68.0.
os:Linux IVI 5.4.134 #1 SMP PREEMPT Tue Mar 18 01:00:37 CST 2025 aarch64 GNU/Linux.
compiler:gcc7.3.
when I called boost::system::error_code.message() like LOG("open error: %...
0
votes
1
answer
98
views
What happens to vtable pointer when upcasting non-pointer object?
I am studying VTable of c++ in university. And maybe I missed something, but I saw following example:
class Parent{
public:
int x;
Parent(int _x) : x(_x){}
virtual void print() const{
...
3
votes
3
answers
188
views
C++ - Trying to understand virtual functions, virtual tables and why does this program seg faults [duplicate]
The following program causes a seg fault.
From printing I saw that no Dtor is called before the crash.
In gdb I saw that each Y object contains a pointer to its vtable.
So when trying to delete an ...
0
votes
1
answer
474
views
how to use ON_CALL and Matcher in gtest with overloaded mocked nfunctions?
I am mocking a class with two overloaded methods like this:
//required because some versions of gtest messes with extra commas in MOCK_METHOD
typedef std::pair<char*, uint32_t> KeyValueType;
...
0
votes
0
answers
179
views
Vuetify, v-data-table-virtual nested scroll bug
I'm trying to implement a virtual data table where when a row is clicked, it shows another embedded data table. However, with the row expanded, when you attempt to scroll the outer table, it gets ...
0
votes
0
answers
31
views
How to determine the cause of a linker error for a derived class [duplicate]
I am unable to decipher a linker error and would like to understand the issue. To provide more context: I have an interface class like below
class ModuleInterface {
public:
virtual ~...
1
vote
0
answers
122
views
C++ 20 modules. duplicate of vtable
Here is the code:
// A.cppm
export module AMOD;
export class A {
public:
virtual ~A() = default;
virtual foo() = 0;
};
// B.cppm
export module BMOD;
import AMOD;
export class B : public A {
...
1
vote
1
answer
97
views
c++ static_cast to virtual base in runtime
Suppose we have such code:
struct Granny {
int g;
};
struct Mom : virtual Granny {
int m;
};
struct Son : Mom {
int s;
};
int main() {
int x;
std::cin >> x;
Mom* mom = (x ? new Son :...
2
votes
1
answer
111
views
Inheritance and Visibility in Swift
I'm confused about the content in the swift doc:
Notice that the initializer for the EquilateralTriangle class has three different steps:
Setting the value of properties that the subclass declares.
...
0
votes
1
answer
104
views
Optimizing calls to derived-class virtual methods from inside of a base-class implementation [duplicate]
Suppose I have an abstract class and derived class like so:
class base {
public:
virtual void pure_func() = 0;
// arbitrary method that makes call(s) to virtual method(s)
virtual void ...
0
votes
1
answer
70
views
Qt6 / Cmake Link error while porting Qt chart example from .pro to cmake. Undefined reference to vtable
For experience, I'm importing chart.cpp and .h from the dynamic spline example (which works perfectly fine on its own) in my own CMake built app. The example is compiled with a .pro file.
I Tuned the ...
0
votes
1
answer
67
views
Why is dynamic dispatch not working within a template function?
I have the following code. There is a base class (Node) and a derived class (NumberExprNode) that each have a virtual equality method.
#include <vector>
#include <memory>
#include <...