vptr Questions
8
Solved
8
Solved
So let's say I have two classes that inherit a base class that has a pure virtual function. Both of the classes implement their own version of that function, but don't add additional member variabl...
3
Solved
I read this question: C++ Virtual class inheritance object size issue, and was wondering why virtual inheritance results in an additional vtable pointer in the class.
I found an article here: http...
Electrophorus asked 13/8, 2019 at 17:47
2
Here, in this code, the size of ob1 is 16 which is fine(because of the virtual pointer) but I can't understand why the size of ob2 is 24.
#include <iostream>
using namespace std;
class A {
...
Vaientina asked 13/8, 2019 at 15:44
1
Solved
I can understand why dynamic_cast does work in this case :
#include <iostream>
struct A{
virtual ~A() = default;
};
struct B {
virtual ~B() = default;
};
struct C : A, B{};
void f(cons...
Chaps asked 4/9, 2018 at 16:48
6
Solved
Let say we have below program:
class A
{ public:
virtual fun(){};
};
class B:public A
{ public:
virtual fun(){};
};
int main()
{
A a1;
B b1;
}
My question is how many vtables and how many v...
5
Solved
Can someone explains how this virtual table for the different class is stored in memory? When we call a function using pointer how do they make a call to function using address location? Can we get...
Argentine asked 25/8, 2017 at 18:34
1
This question is specifically about non-portable MSVC ABI stuff.
I'm trying to write the equivalent of C++'s typeid in obviously-nonportable-yet-not-magic C++. For the Itanium ABI (as used on Linu...
Helsell asked 18/6, 2017 at 18:34
1
Solved
I'm trying to undestand some low-level things with virtual table and inheritance.
When you create new class by inheriting two classes and adding new virtual functions, where exactly the vptr will...
Timisoara asked 24/5, 2017 at 8:9
1
Solved
My understanding of vtables is that, if I have a class Cat with a virtual function speak() with subclasses Lion and HouseCat, there is a vtable which maps speak() to the correct implementation for ...
Rocket asked 17/4, 2017 at 11:2
7
Solved
In Java:
class Base {
public Base() { System.out.println("Base::Base()"); virt(); }
void virt() { System.out.println("Base::virt()"); }
}
class Derived extends Base {
public Derived() { System...
Mihrab asked 18/11, 2012 at 13:7
4
Solved
class base {
public:
void virtual fn(int i) {
cout << "base" << endl;
}
};
class der : public base{
public:
void fn(char i) {
cout << "der" << endl;
}
};
int main()...
Anvil asked 2/2, 2012 at 9:11
1
Solved
I am attempting to implement a system similar to the first described here. That is, the (ab)use of vtable modification to change object behavior at runtime. This is part of my attempts to create an...
Labiodental asked 4/3, 2016 at 16:48
2
Solved
For some compilers, if a class has virtual functions then its vptr can be accessed with the address of the first byte of its object. For instance,
class Base{
public:
virtual void f(){cout<<...
Agent asked 6/11, 2015 at 6:2
11
C++ supports dynamic binding through virtual mechanism. But as I understand the virtual mechanism is an implementation detail of the compiler and the standard just specifies the behaviors of what s...
Umbilical asked 4/12, 2010 at 5:2
3
Solved
Here is the program on vtables. Am I understanding is correct on vtables and v-pointers.
Class B
{
public:
virtual Void Hello()
{
cout<<"Hello Base";
}
};
class D: public B
{
...
3
Solved
This is not about "When VTABLE is created?". Rather, when the VPTR should be initialized? Is it at the beginning/end of the constructor or before/after the constructor?
A::A () : i(0), j(0) -->...
Wilful asked 6/7, 2011 at 5:19
5
Solved
I know that for any class that has a virtual function or a class that is derived from a class that has a virtual function, the compiler does two things. First, it creates a virtual table for that c...
Dinorahdinosaur asked 28/10, 2011 at 20:28
2
Solved
If I have a class Base, with at least one virtual function, and a class Derived which inherits singly from this then (uintptr_t)derived - (uintptr_t)static_cast<Base*>(derived) is guaranteed ...
Europa asked 28/2, 2013 at 19:55
2
Solved
How many vptrs are usually needed for a object whose clas( child ) has single inheritance with a base class which multiple inherits base1 and base2. What is the strategy for identifying how many vp...
Vitia asked 27/7, 2010 at 8:54
2
Solved
As I understand, the location of the virtual function pointer table in an object is compiler dependent.
Are there any pros/cons of placing this pointer at the beginning of the object vs at the end ...
Tenth asked 7/6, 2012 at 3:2
1
Solved
I posted recently a question about the memory overhead due to virtuality in C++. The answers allow me to understand how vtable and vptr works.
My problem is the following : I work on supercomputers...
Cystotomy asked 12/5, 2012 at 8:50
4
This question is not about the C++ language itself(ie not about the Standard) but about how to call a compiler to implement alternative schemes for virtual function.
The general scheme for impleme...
Clothespress asked 12/4, 2012 at 14:2
2
Solved
I was looking at this article, and it says "Upon entry to the base class destructor, the object becomes a base class object, and all parts of C++—virtual functions, dynamic_casts, etc.—treat it tha...
Weatherproof asked 27/10, 2011 at 13:48
5
I am trying to make sense of the statement in book effective c++. Following is the inheritance diagram for multiple inheritance.
Now the book says separate memory in each class is required for vp...
Elishaelision asked 16/4, 2011 at 4:58
1 Next >
© 2022 - 2024 — McMap. All rights reserved.