Reputation: 1483
What is a pseudo-virtual function in C++?
Upvotes: 0
Views: 818
Reputation: 279215
AFAIK it's not a term that appears anywhere with an official definition.
Perhaps someone is talking about simulated dynamic binding?
Edit: a swift web search suggests that someone might have implemented their own dynamic polymorphism, so they perhaps have their own vtables. "Pseudo-virtual" functions would then be functions accessed through their mechanism, rather than actually being virtual functions as their C++ compiler understands them.
One reason to do this would be to implement multi-dispatch.
Do you have any context you can point us at?
Upvotes: 4
Reputation: 340178
I've never heard this term. I'd guess they're either talking about the Non-Virtual Interface idiom (NVI) or they're talking about building a dispatch table of function pointers which is how one might implement polymorphism/virtual functions in C (and in fact is how C++ compilers do it behind the scenes).
Upvotes: 2
Reputation: 3955
A virtual function with a declaration.
class Foo
{
int* bar;
Foo() : bar(0) { bar = new int; }
virtual ~Foo() { delete bar; }
}
This has a pseudo-virtual destructor, since it does something in the declaration. Here is a pure virtual declaration:
class Foo
{
Foo() { }
virtual ~Foo()=0;
}
At least, this is how I learned it.
Upvotes: 0
Reputation: 16281
I have heard the term to used to refer to multimethods (in C++ these are usually implemented using an array of function pointers where the selector offset determined by the code at runtime):
(*multiMethod[ index ])()
The multiMethod array is just an array of function pointers.
Upvotes: 1