virtual-functions Questions
4
Solved
I read a lot of people writing "a virtual table exists for a class that has a virtual function declared in it".
My question is, does a vtable exists only for a class that has a virtual function or...
Scheelite asked 31/1, 2010 at 21:45
1
Solved
I wanted to know how fast is a single-inheritance virtual function call when compared to one same boost::function call. Are they almost the same in performance or is boost::function slower?
I'm aw...
Mord asked 30/1, 2010 at 8:30
3
Solved
Given the following code
class T {
public:
virtual ~T () {}
virtual void foo () = 0;
};
class U {
public:
U() {}
~U() {}
void bar () { std::cout << "bar" << std::endl; }
};
cl...
Zebulon asked 28/1, 2010 at 23:58
3
Solved
In C++, my understanding is that virtual function can be inlined, but generally, the hint to inline is ignored. It seems that inline virtual functions do not make too much sense.
Is that right?
C...
Kingfish asked 25/1, 2010 at 4:38
8
Consider this simple situation:
A.h
class A {
public:
virtual void a() = 0;
};
B.h
#include <iostream>
class B {
public:
virtual void b() {std::cout << "b()." << std::en...
Printery asked 20/1, 2010 at 21:52
3
Solved
I have something similar to this in my code:
#include <iostream>
#include <cstdlib>
struct Base
{
virtual int Virtual() = 0;
};
struct Child
{
struct : public Base
{
virtual int ...
Briolette asked 17/1, 2010 at 19:45
6
Solved
I have some questions about the object size with virtual.
1) virtual function
class A {
public:
int a;
virtual void v();
}
The size of class A is 8bytes....one integer(4 bytes) plus one vir...
Schwerin asked 10/1, 2010 at 21:33
6
Solved
When exactly does the compiler create a virtual function table?
1) when the class contains at least one virtual function.
OR
2) when the immediate base class contains at least one virtual funct...
Kaceykachina asked 26/12, 2009 at 18:2
5
Solved
In object-oriented programming, it's sometimes nice to be able to modify the behavior of an already-created object. Of course this can be done with relatively verbose techniques such as the strateg...
Fatigue asked 20/12, 2009 at 16:35
9
Solved
I'm having trouble understanding what the purpose of the virtual keyword in C++. I know C and Java very well but I'm new to C++
From wikipedia
In object-oriented programming, a
virtual funct...
Ragi asked 1/12, 2009 at 21:21
2
Solved
I have been using Moq recently in my development process and I like what I am able to achieve.
However, I find myself making my methods (and properties for the mostpart) virtual so that I can repla...
Unsuspected asked 21/11, 2009 at 7:40
2
Solved
i have the following classes:
class A {
protected:
A *inner;
public:
....
virtual void doSomething() = 0;
....
}
class B: public A {
...
void doSomething() {
if(inner != NULL)
inner->d...
Interpret asked 30/9, 2009 at 15:14
4
Solved
I have a base class that I want to look like this:
class B
{
// should look like: int I() { return someConst; }
virtual int I() = 0;
public B() { something(I()); }
}
The point being to force ...
Cunctation asked 21/9, 2009 at 6:42
8
Solved
I have an abstract class in a library. I'm trying to make it as easy as possible to properly implement a derivation of this class. The trouble is that I need to initialize the object in a three-ste...
Anthology asked 20/7, 2009 at 19:4
7
I just spotted this in some code:
class Foo {
[...]
private:
virtual void Bar() = 0;
[...]
}
Does this have any purpose?
(I am trying to port some code from VS to G++, and this caught my atten...
Rizzio asked 15/7, 2009 at 20:49
8
Solved
I'm learning about C++ in a class right now and I don't quite grok pure virtual functions. I understand that they are later outlined in a derived class, but why would you want to declare it as equa...
Rheum asked 1/7, 2009 at 20:7
3
Solved
I was trying to figure out what happens when a derived class declares a virtual function as private. The following is the program that I wrote
#include <iostream>
using namespace std;
class ...
Pickar asked 30/6, 2009 at 4:28
7
Solved
Profiling my C++ code with gprof, I discovered that a significant portion of my time is spent calling one virtual method over and over. The method itself is short and could probably be inlined if i...
Garv asked 1/4, 2009 at 0:11
6
Solved
Following up on this comment from the question Writing firmware: assembly or high level?:
When compiling C++ code for the Arduino platform, can you use virtual functions, exceptions, etc? Or woul...
Cleisthenes asked 20/1, 2009 at 15:44
3
Solved
For performance reasons, I am using the the Curiously Reoccuring Template Pattern to avoid virtual functions. I have lots of small commands which execute millions of times. I am trying to fit this ...
Supernatural asked 11/6, 2009 at 0:14
5
Solved
Is there anyway to have a sort of virtual static member in C++?
For example:
class BaseClass {
public:
BaseClass(const string& name) : _name(name) {}
string GetName() const { return _name;...
Malagasy asked 29/8, 2008 at 15:54
6
Solved
In C++, I have to explicitly specify 'virtual' keyword to make a member function 'overridable', as there involves an overhead of creating virtual tables and vpointers, when a member function is mad...
Hermineherminia asked 7/5, 2009 at 19:56
9
Solved
If I want to make a class adaptable, and make it possible to select different algorithms from the outside -- what is the best implementation in C++?
I see mainly two possibilities:
Use an abstra...
Heartbeat asked 2/3, 2009 at 14:49
4
Solved
I found the following code in a library:
class Bar {
public:
bool foo(int i) {
return foo_(i);
}
private:
virtual bool foo_(int i) = 0;
};
Now I'm wondering: Why would you use this indirecti...
Sandler asked 19/3, 2009 at 17:50
6
I have a diamond multiple inheritance scenario like this:
A
/ \
B C
\ /
D
The common parent, A, defines a virtual function fn().
Is it possible for both B and C to define fn()?
If it is, th...
Propagation asked 5/3, 2009 at 19:59
© 2022 - 2024 — McMap. All rights reserved.