virtual-functions Questions
2
Solved
I have a base class in which I have a pure virtual function and with this function, I want to override it in other derived classes (in some of those with a different number of parameters if possibl...
Harmonyharmotome asked 24/8, 2020 at 17:25
7
Solved
class GrandParent
{
public virtual void Foo() { ... }
}
class Parent : GrandParent
{
public override void Foo()
{
base.Foo();
//Do additional work
}
}
class Child : Parent
{
public overri...
Hydric asked 2/8, 2011 at 14:19
4
Solved
I'm curious how performant the Expression.Compile is versus lambda expression in the code and versus direct method usage, and also direct method calls vs virtual method calls (pseudo code):
var fo...
Sabbatarian asked 4/3, 2016 at 20:39
13
Solved
I got this question when I received a code review comment saying virtual functions need not be inline.
I thought inline virtual functions could come in handy in scenarios where functions are call...
Ctesiphon asked 9/4, 2009 at 11:3
8
Solved
In Java you can mark method as final to make it impossible to override.
In C# you have to mark method as virtual to make it possible to override.
Does it mean that in C# you should mark all metho...
Dysgenics asked 22/1, 2013 at 3:54
2
Solved
I have C++ program that reads a config file when the binary is executed, creates a number of child class instances based on the config file, and then periodically iterates over these instances and ...
Threadfin asked 21/3, 2020 at 0:16
10
What 's the practical usage of virtual functions in c#?
Integration asked 30/6, 2009 at 6:54
4
Solved
What does the keyword virtual do when overriding a method? I'm not using it and everything works fine.
Does every compiler behave the same in this regard?
Should I use it or not?
Apoenzyme asked 18/6, 2011 at 16:31
18
Solved
I'm getting a warning from ReSharper about a call to a virtual member from my objects constructor.
Why would this be something not to do?
Henig asked 23/9, 2008 at 7:11
1
Before you down-vote or start saying that gotoing is evil and obsolete, please read the justification of why it is viable in this case. Before you mark it as duplicate, please read the full questio...
Putscher asked 8/11, 2019 at 21:47
2
Solved
In this example, classes Foo and Bar are provided from a library. My class Baz inherits from both.
struct Foo
{
void do_stuff (int, int);
};
struct Bar
{
virtual void do_stuff (float) = 0;
};
...
Altissimo asked 4/11, 2019 at 17:12
3
Solved
Consider the following code:
struct A {
virtual A& operator+=(const A& other) noexcept = 0;
};
void foo_inner(int *p) noexcept { *p += *p; }
void foo_virtual_inner(A *p) noexcept { *p +=...
Hurried asked 1/4, 2019 at 22:42
3
Solved
when a base class pointer points to the object of it's derived class and if a function being overridden we use virtual function to solve the problem . So that we can access the own function of deri...
Peres asked 16/7, 2019 at 8:26
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
4
Solved
I am new to C++. While trying sample polymorphism code, I found that base class virtual function definition in derived class is possible only when defined within the derived class or outside with d...
Cyn asked 21/12, 2010 at 11:25
2
The Class B is overriding the pure Virtual Function "print()" of class A. Class C is inheriting Class B as well as having a "using A::print" statement.
Now why Class C is not an abstract class?
c...
Ezekielezell asked 4/1, 2019 at 12:21
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
2
Solved
I have a few heavily optimized math functions that take 1-2 nanoseconds to complete. These functions are called hundreds of millions of times per second, so call overhead is a concern, despite the ...
Countersink asked 14/12, 2018 at 19:35
9
Solved
With the struct definition given below...
struct A {
virtual void hello() = 0;
};
Approach #1:
struct B : public A {
virtual void hello() { ... }
};
Approach #2:
struct B : public A {
voi...
Circularize asked 4/2, 2011 at 6:46
3
Solved
I'm curious if marking an existing derived C++ class as final to allow for de-virtualisation optimisations will change ABI when using C++11. My expectation is that it should have no effect as I see...
Irrigate asked 20/11, 2018 at 7:10
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
10
Solved
I just read that we should not use virtual function excessively. People felt that less virtual functions tends to have fewer bugs and reduces maintenance.
What kind of bugs and disadvantages can a...
Malang asked 16/6, 2010 at 4:57
5
Solved
Very often, when I program, I use polymorphism because it naturally models the objects that I need. On the other hand I very often use standard containers to store these objects, and I tend to avoi...
Redintegrate asked 9/6, 2014 at 17:36
12
Solved
We all know what virtual functions are in C++, but how are they implemented at a deep level?
Can the vtable be modified or even directly accessed at runtime?
Does the vtable exist for all classes...
Stenotypy asked 19/9, 2008 at 3:29
5
Solved
Why does this happen?
http://coliru.stacked-crooked.com/a/e1376beff0c157a1
class Base{
private:
virtual void do_run() = 0;
public:
void run(){
do_run();
}
};
class A : public Base {
public:
...
Mountaineer asked 6/6, 2018 at 14:23
© 2022 - 2024 — McMap. All rights reserved.