virtual

What good is virtual in a class ?

Possible Duplicate: C++ Virtual/Pure Virtual Explained For example i have: class A { private: int i; int j; public: void k (int l, int m) { i=l; j=m; } virtual int n (void); }; class B : public A { public: int n (void); }; What good is this virtual ? ...

base class 'class std::vector<...>' has a non-virtual destructor

One of my C++ classes derives from std::vector so that it can act as a container that also perform custom actions on its content. Unfortunately, the compiler complains about the destructor not to be virtual, which I cannot change, since its in the standard library. Am I doing the whole thing wrong (thou shall not derive from STL) or is ...

Inheritance and templates and virtual functions ( this can get messy)

Just finding my way around templates so was trying out a few stuff. Let me know what I am doing wrong here. I am trying to overload a inherited templates virtual method. // class templates #include <iostream> using namespace std; template <class T, class A> class mypair { T a, b; public: mypair (T first, T second) {a...

Virtual keyboard Popup not working on a derived textbox in wpf

Hi. I have a derived class called NumericTextBox that is derived from TextBox.This has all the validationsf for the data to be numeric. Now, i have a popup attached to this textbox in my window. the popup is a virtual keyboard. this lets the user input from both Keyboard and Mouse. but whenever i click a button on the popup, the PreivewT...

Enforce third party methods virtuality

I'm extending a class provided by a third part library. The class, let's call it Foo, has a reset() method which can be called in order to restart Foo's behavior. The reset() method is also used internally by the class. class Foo { public: void reset () { /* ... */ } void something () { reset(); } }; ...

Why are C# interface methods not declared abstract or virtual?

C# methods in interfaces are declared without using the virtual keyword, and overridden in the derived class without using the override keyword. Is there a reason for this? I assume that it is just a language convenience, and obviously the CLR knows how to handle this under the covers (methods are not virtual by default), but are there...

Interpreter Speeds

I want to do my best on a cool personal project I have in mind, and I need to choose between an interpreter (slow and lightweight in memory) and a virtual machine (faster and heavy). Is true that interpreters are much slower than virtual machines, at a point which it is visible to the user? Somebody have done a comparison? Thanks! ...

C# design: Why is new/override required on abstract methods but not on virtual methods?

Hi all Why is new/override required on abstract methods but not on virtual methods? Sample 1: abstract class ShapesClass { abstract public int Area(); // abstract! } class Square : ShapesClass { int x, y; public int Area() // Error: missing 'override' or 'new' { return x * y; } } The compiler will show ...

Two really similar classes in C++ with only one different method: how to implement?

Hi all, I have two classes that are almost identical, besides one method. The classes have the same data part and all the member functions but one: class A { private: double data; public: double calc(){ return data*data; } double especific(){ return 2.0*data; } } and the second class is identical, besides the es...

virtual functions are determine during the compilation?

i tried to look up whether virtual function determine during compilation or while running. while looking i found something as dynamic linking/late binding but i didn't understand if it means that the function itself determine during compilation before the executable or during the executable. can someone please explain? ...

Java awt.Robot: send key with position for eg. right shift or right ctrl

Hello, I want to use the java.awt.Robot class to implement a virtual keyboard. I am wondering if there is a way to send the keycode WITH the key location (left or right) using the keyPress(int) method. If you add a KeyListener to an awt Element, a KeyEvent triggered by ctrl or shift has an information if it was the left or right button....

Programatically determine virtual host in J2EE servlet?

I'm attempting to programatically locate the virtual hostname for a J2EE servlet container. In this enterprise environment, the logical URL consists of protocol://application.company.com/, which is translated to protocol://virtualhost.datacenter.company.com:port/context/. Using ServletRequest.getServerName() gives me "application.compa...

Virtual function implemented in base class not being found by compiler

I've got a situation where it seems like the compiler isn't finding the base class definition/implementation of a virtual function with the same name as another member function. struct One {}; struct Two {}; struct Base { virtual void func( One & ); virtual void func( Two & ) = 0; }; struct Derived : public Base { virtual...

Flash / Flex virtual tour of room

Hello! I want to make a virtual tour of a room in Flash / Flex. How can this be achieved? Firstly, is it enough to have pictures taken from a still point? If yes, how can I turn them into a real tour? Also, is there a library for this kind of thing for AS3? Thank you. ...

simple install for vm appliance??

I need to create a virtual machine appliance (guest: linux, host: win xp/vista/7). I would like to minimize the install process as much as possible. For example, installing VirtualBox + my VM is too much for the end user. I would ideally like a single EXE, "zero-install" solution, but don't know if it exists. I can use qemu or virtua...

Force virtual destructors? C++

I didnt see it in the C++ Faq lite How do i define a base class so every class inheriting it is required to define a destructor? I tried running this program struct VDtor { virtual ~VDtor()=0; }; struct Test:VDtor { virtual ~Test(){} }; int main() { delete new Test; return 0; } http://codepad.org/wFcE71w3 With the error In functi...

A scenario where static virtual methods make sense

I know that virtual and static methods are opposing concepts, but I think that it could make sense sometimes to use them together. There have been quite a bunch of similiar question on SO on this topic, but the following scenario has not been covered yet. There's a C# interface that looks like this: interface IVertexMeshLoader { Ve...

How can a base class satisfy the definition of a parent's pure virtual function using another parent's function (C++)

I am extending an existing C++ project. I have a base class that derives from two parent classes. One of the parents has a pure virtual function. I want that pure virtual function to be defined by a function implemented in the other parent. So, I want another parent to satisfy the base class's obligation to define a parent's pure vir...

C++ Virtual Destructor Crash

I have the following class hierarchy: class Base { public: virtual ~Base(); }; class Derived : public Base { public: virtual ~Derived(); }; class MoreDerived : public Derived { public: virtual ~MoreDerived(); }; along with an objects Base* base = new Base(); MoreDerived* obj = new MoreDer...

How to change implementation of returned object base class's function when object is returned C++

I have an existing application in C++ with a custom ArrayBase class that manages storage and access to a contiguously allocated region of memory. I have a separate ItrBase class that is used to access data in that ArrayBase. ArrayBase has a createItr() function that currently returns an ItrBase object. I need to extend ArrayBase to us...