virtual

C++ Multiple inheritance with interfaces?

Greetings all, I come from Java background and I am having difficulty with multiple inheritance. I have an interface called IView which has init() method.I want to derive a new class called PlaneViewer implementing above interface and extend another class. (QWidget). My implementation is as: IViwer.h (only Header file , no CPP file) ...

VSC++, virtual method at bad adress, curious bug

Hello, This guy: virtual phTreeClass* GetTreeClass() const { return (phTreeClass*)m_entity_class; } When called, crashed the program with an access violation, even after a full recompile. All member functions and virtual member functions had correct memory adresses (I hovered mouse over the methods in debug mode), but this function h...

C++ Virtual Destructors

When creating prototype classes I lay out the destructor as such: virtual ~MyClass(); When finalizing the class in a library I noticed that I cannot add 'virtual'. Is this normal, and is virtual taken into consideration or am I do something wrong? For example; when I try to do this I get a compiler error: virtual MyClass::~MyClass()...

Can I use an HTML base tag to resolve a virtual directory?

I have an ASP.NET MVC web application running in IIS as a subweb; let's say its path is something like http://mysite.com/subweb. I have a view which serves content obtained from a CMS. The CMS editor has entered some content containing a relative image path <img src="/images/imga.png" />. This works fine on the production server where...

Interview question about virtual functions in C++

I was asked this crazy question. I was out of my wits. Can a method in base class which is declared as virtual be called using the base class pointer which is pointing to a derived class object? Is this possible? ...

How do you return a pointer to a base class with a virtual function?

I have a base class called Element, a derived class called Vector, and I'm trying to redefine two virtual functions from Element in Vector. //element.h template <class T> class Element { public: Element(); virtual Element& plus(const Element&); virtual Element& minus(const Element&); }; and in another file //Vector.h #include "Eleme...

Just how much do I want to make virtual?

I am writing an abstract superclass where literally every method is going to be overridden. There is some default functionality I could implement, but most of the time it's enough to leave the implementation to the subclass writer. Since just about every method is going to be overwritten, how much should I make virtual and how much sho...

print address of virtual member function

I am trying to print the address of a virtual member function. If I only wants to print the address of the function I can write: print("address: %p", &A::func); But I want to do something like this: A *b = new B(); printf("address: %p", &b->func); printf("address: %p", &b->A::func); however this does not compile, is it possible t...

C++ vtable resolving with virtual inheritance

I was curious about C++ and virtual inheritance - in particular, the way that vtable conflicts are resolved between bass and child classes. I won't pretend to understand the specifics on how they work, but what I've gleamed so far is that their is a small delay caused by using virtual functions due to that resolution. My question then is...

wxPython: VirtualTreeListCtrl with millions of items

I would like to add 1,000,000+ entries to the root node of a TreeListCtrl. Therefore I would like to make it "virtual", i.e. work just like a virtual ListCtrl so that it's still fast and I can easily scroll around due to the currently-displayed items being loaded on-demand. But I can't use a virtual ListCtrl because I also want to be abl...

Python virtual classes: doing it right ?

I have been reading documentation describing class inheritance, abstract base classes and even python interfaces. But nothing seams to be exactly what I want. Namely, a simple way of building virtual classes. When the virtual class gets called, I would like it to instantiate some more specific class based on what the parameters it is giv...

How do you set up a virtual environment or sandbox for ruby without removing access to external API's?

I am running a bit of code that looks like this: result = system("ruby " + filename_random_ruby_script) if result save_to_disk(random_ruby_script) else # Do Nothing end The variable "random_ruby_script" represents any .rb file. This code is the first of many calls to system() and runs a ruby file that may also contain calls to sy...

Why are private virtual methods illegal in C#?

Coming from a C++ background, this came as a surprise to me. In C++ it's good practice to make virtual functions private. From http://www.gotw.ca/publications/mill18.htm: "Guideline #2: Prefer to make virtual functions private." I also quote Eric Lippert's blog, from http://blogs.msdn.com/b/ericlippert/archive/2010/03/25/knights-knaves-...

Simulate multiple MAC addresses on same network adapter

Hi, I have a network management software which profiles network devices based on their MAC addresses. I want to write a tool to stress test this software by using virtual MAC addresses (simulate thousands of devices each having a different MAC address). I played around with WinPCap and found that I can send a packet with spoofed up MAC...

c++ inherit from a virtal base class

I want to do the following: class ErrorBase { public: void SetError(unsigned errorCode) { mErrorCode = errorCode; } char const* Explanation(unsigned errorCode) const { return errorExplanations[errorCode]; } private: char const* errorExplanations[]; unsigned mErrorCode; }; class MyErro...

How do I access localhost ports on a virtual pc?

I've downloaded and installed the Microsoft Virtual PC and Windows XP mode image for testing IE6. I have several projects on localhost that I access by port numbers in my vhosts file, for example: Listen *:82 <VirtualHost *:82> DocumentRoot "path/to/htdocs/project-folder/public/" </VirtualHost> In the virtual machine I have change...

WAMP Virtual Hosts Not Working

Hi guys, please help me, I am pulling my hair out. I cannot get Virtual Hosts to work with WAMP. I have uncommented out this line: # Virtual hosts Include conf/extra/httpd-vhosts.conf This is my httpd-vhosts.conf file: # # Virtual Hosts # # If you want to maintain multiple domains/hostnames on your # machine you can setup VirtualHos...

Test for overhead of virtual functions

I set up a (perhaps very unscientific) small test to determine the overhead of virtual functions in a one-level single inheritance and the results I got were, well, exactly the same when accessing the derived class polymorphically or when accessing it directly. What was a bit surprising was the order of magnitude of computation time that...

C++ virtual override functions with same name

Hello there, I have something like that (simplified) class A { public: virtual void Function () = 0; }; class B { public: virtual void Function () = 0; }; class Impl : public A , public B { public: ???? }; How can I implement the Function () for A and the Function() for B ? Visual C++ lets you only define the s...

Do I need to specify virtual on the sub-classes methods as well ?

This has probably been asked before on SO, but I were unable to find a similar question. Consider the following class hierarchy: class BritneySpears { public: virtual ~BritneySpears(); }; class Daughter1 : public BritneySpears { public: virtual ~Daughter1(); // Virtual specifier }; class Daughter2 : public BritneySpears...