Here's the deal. I have a big class hierarchy and I have this one method that is extended all the way through. The method always has to look at one or two more variable at each new level and these variable depend on the actual class in the hierarchy. What I want to do is check those two extra variables then call the superclass's version ...
Java and C# support the notion of classes that can't be used as base classes with the final and sealed keywords. In C++ however there is no good way to prevent a class from being derived from which leaves the class's author with a dilemma, should every class have a virtual destructor or not?
On the one hand giving an object a virtual d...
In my C++ program (on Windows), I'm allocating a block of memory and can make sure it stays locked (unswapped and contiguous) in physical memory (i.e. using VirtualAllocEx(), MapUserPhysicalPages() etc).
In the context of my process, I can get the VIRTUAL memory address of that block,
but I need to find out the PHYSICAL memory addres...
I have a base class with a virtual method, and multiple subclasses that override that method.
When I encounter one of those subclasses, I would like to call the overridden method, but without knowledge of the subclass. I can think of ugly ways to do this (check a value and cast it), but it seems like there should be an in-language way t...
I have a weird error in my C++ classes at the moment. I have an ActiveX wrapper class (as part of wxWidgets) that i added a new virtual function to. I have another class that inherits from the ActiveX one (wxIEHtmlWin) however the ActiveX class always calls its own function instead of the one in wxIEHtmlWin which overrides it.
I can't w...
Say we have:
Class Base
{
virtual void f(){g();};
virtual void g(){//Do some Base related code;}
};
Class Derived : public Base
{
virtual void f(){Base::f();};
virtual void g(){//Do some Derived related code};
};
int main()
{
Base *pBase = new Derived;
pBase->f();
return 0;
}
Which g() will be c...
How do you declare a method in C# that should be overridden (or overridable) by a dereived class - possibly even outside your assembly - but that should be callable only from within the actual class?
(i.e. like a private virtual function in C++)
[edit]
private virtual is exactly what I intend: "Here's a way to modify my behavior, but y...
I set up a website and I created a folder names (docs) in the website as Virtual Directory with some documents.
Therefore the URL is xxxxxxyyyyzzzz.com/docs
The problem is that when i try to access xxxxxxyyyyzzzz.com/docs/1.doc, Authentication is required. Can you tell me how to remove this and leave any user access this folder with a...
What is the meaning of "virtual" inheritance?
I saw the following code, and I don't understand what is the meaning of the word "virtual" in the following context:
class A {};
class B : public virtual A;
Thanks!
...
Is there any real performance gain on a virtual hosting over a shared hosting? Do you recommend any virtual hosting costing bellow $100?
...
Could someone explain why both tests using the latest versions of Moq and Rhino.Mocks frameworks fail complaining that Bar is not a virtual/overridable method:
public interface IFoo
{
string Bar();
}
public class Foo : IFoo
{
public string Bar()
{
return "Bar";
}
}
[TestMethod]
public void MoqTest()
{
var f...
Imagine a standard diamond inheritance. Class A defines pure virtual function fx, class B defines implementation for fx, classes C and D do nothing with fx. When trying to call fx on instance of class D you'll get 'ambiguous function call' error although there is only one implementation of fx. This can be solved by B and C inheriting fro...
How are the virtual functions work in C# and Java ? Does it use same vtable and vpointer concept similar to C++ or is it something totally different?
...
Hi,
I have a solid understanding of most OO theory but the one thing that confuses me a lot is virtual destructors.
I thought that the destructor always gets called no matter what and for every object in the chain.
When are you meant to make them virtual and why?
...
Let's say we have
class A {
public:
virtual int foo() { cout << "foo!"; }
}
class B : public A {
public:
virtual int foo() =0;
}
class C : public B {
public:
virtual int foo() { cout << "moo!"; }
}
Is this really overriding? I think this is actually overloading.
What is the meaning of making something lik...
Why the following example prints "0" and what must change for it to print "1" as I expected ?
#include <iostream>
struct base {
virtual const int value() const {
return 0;
}
base() {
std::cout << value() << std::endl;
}
virtual ~base() {}
};
struct derived : public base {
virtual const int value() const {
...
I've got a little class hierarchy where each class corresponds to a certain TComponent descendent (say base class TDefaultFrobber with descendents TActionFrobber and TMenuItemFrobber, corresponding to TComponent, TCustomAction and TMenuItem, respectively). Now I want a factory (?) function something like this:
function CreateFrobber(ACo...
Maybe Im to tired, but this seems to be a vary basic question. Suddenly my inheritance chain stopped working. Writing a small basic test application proved that it was me that was wrong (so I cant blame the compiler).
I have a base class, with the default behavior in a virtual function. A child class derives from that and changes the be...
Most of the literature on Virtual Memory point out that the as a Application developer,understanding Virtual Memory can help me in harnessing its powerful capabilities. I have been involved in developing applications on Linux for sometime but but didn't care about Virtual Memory intricacies while I code. Am I missing something? If so, pl...
Question is as stated in the title: What are the performance implications of marking methods / properties as virtual?
Note - I'm assuming the virtual methods will not be overloaded in the common case; I'll usually be working with the base class here.
...