virtual-functions Questions

8

I know that derived classes can simply "redefine" base class member functions, and that when that function of a derived class object is called, the function defined in the derived class is used, bu...
Coheir asked 3/2, 2011 at 2:26

2

Solved

How do we call a virtual method from another method in the base class even when the current instance is of a derived-class? I know we can call Method2 in the Base class from a method in the Derive...
Adlai asked 29/3, 2012 at 8:56

2

Solved

Possible Duplicate: C++ static virtual members? Can we have a static virtual functions? If not, then WHY? class X { public: virtual static void fun(){} // Why we cant have static vi...
Eureka asked 25/3, 2012 at 18:54

5

Solved

In C++ why the pure virtual method mandates its compulsory overriding only to its immediate children (for object creation), but not to the grand children and so on ? struct B { virtual void foo (...

1

Solved

I'm trying to implement the Heigh-for-width Geometry Management in GTK with Python for my custom Widget. My widget is a subclass from Gtk.DrawingArea and draws some parts of an Image. As I underst...
Konyn asked 29/2, 2012 at 9:14

4

Solved

class base{ ..... virtual void function1(); virtual void function2(); }; class derived::public base{ int function1(); int function2(); }; int main() { derived d; base *b = &d; int k =...
Timtima asked 24/2, 2012 at 5:25

3

Solved

I have a particular scenario below. The code below should print 'say()' function of B and C class and print 'B says..' and 'C says...' but it doesn't .Any ideas.. I am learning polymorphism so also...
Gyrus asked 11/2, 2012 at 16:7

2

Solved

I understand that a class will have a VTABLE, if it contains at-least one virtual function. I would like to see the contents of the VTABLE. Is there a way to display it ? Specifically, is there an...
Aidoneus asked 22/1, 2012 at 7:4

5

Solved

Consider the example below: #include <iostream> using namespace std; class base { public: virtual int func() { cout << "vfunc in base class\n"; return 0; } }; class derived: p...
Kktp asked 23/1, 2012 at 4:49

4

Solved

Possible Duplicate: Can someone explain C++ Virtual Methods? I have a question regarding to the C++ virtual functions. Why and when do we use virtual functions? Can anyone give me a...
Miniver asked 11/1, 2012 at 18:6

0

I did some study to find out why a constructor cannot be virtual. I am consolidating my understanding here. I will first explain what is a virtual function and then explain why a constructor...
Henleigh asked 15/12, 2011 at 6:22

5

Solved

In one of the C++ tutorials in internet, i found out the below description on why a constructor cannot be virtual We cannot declare a virtual constructor. We should specify the exact type of th...
Retention asked 14/12, 2011 at 15:18

7

Solved

I was just trying to master the concept of virtual function using a console app. I noticed as soon as I override a base class function, return baseclassname.functionname(parameters) gets inserted i...
Spermiogenesis asked 29/11, 2011 at 10:42

2

Solved

Using pure virtual methods for faux-interfaces in C++, what happens when a concrete class derives from two 'interfaces' which have an identical method declaration? e.g X sub-classes Iaaa and Ibbb a...
Utterance asked 24/10, 2011 at 8:27

6

Solved

I have a bunch of systems, lets call them A, B, C, D, E, F, G, H, I, J. They all have similar methods and properties. Some contain the exact same method and properties, some may vary slightly and ...
Naamann asked 28/9, 2011 at 20:24

1

Solved

Base class has a function f. Derived class overwrites the function f. I want to call base class' f for an object of the derived class. How can I do this? Here is the code sample. classdef base ...
Serial asked 16/9, 2011 at 12:53

1

Solved

Years ago I was learning about x86 assembler, CPU pipelining, cache misses, branch prediction, and all that jazz. It was a tale of two halves. I read about all the wonderful advantages of the leng...

5

Solved

Is it possible to determine if a virtual method has been overridden: class ABase { public void DoSomething(object p) { p.Process(); if( /* DoSomethingExtra is implemented */ ) DoSometh...
Rousseau asked 29/8, 2011 at 18:0

3

If you have a struct like this one struct A { void func(); }; and a reference like this one A& a; you can get a pointer to its func method like this: someMethod(&A::func); Now wha...
Ulrikeulster asked 19/7, 2011 at 22:18

3

Solved

Suppose a construct like this: class Interface { public: template <typename T> virtual void reportOperationError(T code , std::string message) = 0; }; i don't understand the use case for...
Sedda asked 10/7, 2011 at 15:13

11

Solved

I know that virtual functions have an overhead of dereferencing to call a method. But I guess with modern architectural speed it is almost negligible. Is there any particular reason why all func...
Voroshilovgrad asked 7/7, 2011 at 6:24

2

Solved

Is CRTP capable enough to outsmart virtual functionality completely ? The only disadvantage I see with CRTP is notable amount of code generated for every recurring pattern. For smaller designs, (w...
Khedive asked 7/7, 2011 at 16:18

4

From what I know of CPP, each class has its own vtable. However this wikipedia link mentions: An object's dispatch table will contain the addresses of the object's dynamically bound methods....
Jambeau asked 7/7, 2011 at 6:6

4

Solved

I am in a situation where I have game objects that have a virtual function Update(). There are a lot of game objects (currently a little over 7000) and the loop calls update for all of them (amongs...
Avraham asked 6/7, 2011 at 15:37

3

Solved

Suppose I have a class with a virtual function and a derived class that implements the virtual function in a different way. Suppose I also have a vector of the base class used to store derived clas...
Neibart asked 5/6, 2011 at 0:19

© 2022 - 2024 — McMap. All rights reserved.