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 ?
...
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 ...
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...
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...
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();
}
};
...
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...
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!
...
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 ...
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...
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?
...
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....
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...
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...
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.
...
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...
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...
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...
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...
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...
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...