virtual

[C#] designing virtual methods

Hello, I wonder under what circumstances you would choose the first or the second design : First design : the child method have to call the base method public abstract class Base { public virtual void Enable() { IsEnable = true; } public virtual void Disable() { IsEnable = false; } public bool IsEnable { get; private set...

Virtual functions table offset

Hello. I would like to ask you on what does the offset of the table of virtual functions for a class depend? I mean, from what I've read it at least depends on compiler, but does it varies from class to class? Edit: by offset I mean the position of the table relative to the address of the owner object. Edit: example code: void **vtabl...

gcc c++ virtual inheritance problem

Problem: class Base { public: Base(Base* pParent); ... implements basic stuff... }; class A : virtual public Base { public: A(A* pParent) : Base(pParent) {} ... }; class B : virtual public Base { public: B(B* pParent) : Base(pParent) {} ... }; class C : public A, public B { public: C(C* pParent) : A(pParent), B(pParent) {} ...

Operator== in derived class never gets called.

Can someone please put me out of my misery with this? I'm trying to figure out why a derived operator== never gets called in a loop. To simplify the example, here's my Base and Derived class: class Base { // ... snipped bool operator==( const Base& other ) const { return name_ == other.name_; } }; class Derived : public Base { // ......

How to prevent derived class from making a private/protected virtual function public?

There are good reasons for constructing the base class interface with all virtual functions as private or protected (see this). But then how does one prevent the derived classes (which may be in the hands of external clients) from making the private virtual function as public? In Virtually Yours, the authors talk about this problem, but ...

One click virtual machine demo?

I want to give a demo for my customers use virtual machine, but I don't want the customer to install the virtual machine software, can I make a demo which bundle the virtual machine software and my virtual machine, then just a click to run the virtual machine. It will be cool. is there any tool can do that? ...

Why pure virtual function is initialized by 0?

We always declare a pure virtual function as : virtual void fun () = 0 ; i.e. it is always assigned to 0. What I understand is that this is to initialize the vtable entry for this function to NULL and any other value here results in a compile time error. Please tell me whether this understanding is correct or not. ...

Virtual Scrolling / Paging

Hi all, I was wondering if anyone know of examples out there on how to page a List of data via scrolling. (i.e. like yahoo mail) Thanks ...

Virtual Table C++

I read a lot of people writing "a virtual table exists for a class that has a virtual function declared in it". My question is, does a vtable exists only for a class that has a virtual function or does it also exist for classes derived from that class. e.g class Base{ public: virtual void print(){cout<<"Base Print\n";} };...

ELF binary entry point

why is the entry point in each ELF binary something starting with 0x80xxxxx? Why doesn't the program start at (virtual) address 0x0? When executed, program will start running from virtual address 0x80482c0 (see entry point address). The "0x" prefix here means it is a hexadecimal number. This address doesn't point to our main() procedure...

Virtual Printer Driver for Windows

Hello, can you please help me with the following questions... If I need a virtual printer that will convert a PostScript stream to a different format, do I have to implement a virtual printer from scratch or implement a rendering plug-in? The rendering plug-in seems to support only certain customizations. Also the data invariably goes ...

Postfix - Virtual Domains: 550-Mailbox unknown

I'm creating new email accounts through Godaddy Simple Control Panel. After creating email account, trying to send test email n i'm getting below error. The mail system <[email protected]>: host ip.secureserver.net[/var/lib/imap/socket/lmtp] said: 550-Mailbox unknown. Either there is no mailbox associated with this 550-name...

Are virtual destructors inherited?

If I have a base class with a virtual destructor. Has a derived class to declare a virtual destructor too? class base { public: virtual ~base () {} }; class derived : base { public: virtual ~derived () {} // 1) ~derived () {} // 2) }; Concrete questions: Is 1) and 2) the same? Is 2) automatically virtual because of its...

In C++ when should someone make a private function virtual?

Possible Duplicate: Why would a virtual function be private? I've seen private virtal functions declared here and their in C++ but I'm not entirely sure as to its purpouse design wise, are their any cases where it is beneficial to have a private virtual function? ...

How to implement a button that functions like typing words in Cocoa with IMKits?

In fact, i am implementing a virtual keyboard for my input method with Input-method Kits (IMKits). How can i achieve this? Which functions i need to override? Appreciated for help. ...

Using 'virtual' in derived class

I saw code in a derived class recently in which the programmer put virtual in front of the functions overridden. Is this common? I thought it was very odd and it kind of caught me off guard. Edit: I'm not asking what virtual does, I'm asking why someone would put virtual in a derived class that is already overriding virtual functions i...

MSVC Object Layout Quirk

I have a simple class in C++ that has an integer and a vtable: class Something { virtual void sampleVirtualMethod(); int someInteger; }; If you look at the object layout for MSVC (using the /d1reportSingleClassLayout) you get: class Something size(8): +--- 0 | {vfptr} 4 | someInteger +--- W...

How to write a virtual printer driver for Mac OSX

I need to write a "virtual printer driver" for OSX, so that when the user presses Command+P to open the Print dialog, he sees my virtual printer...which will be used to generate files of various types, instead of physically printing to paper. I'm new to the subject, I looked around a bit but found nothing. Do you have any link or refere...

Virtual Serial Device in Python?

I know that I can use e.g. pySerial to talk to serial devices, but what if I don't have a device right now but still need to write a client for it? How can I write a "virtual serial device" in Python and have pySerial talk to it, like I would, say, run a local web server? Maybe I'm just not searching well, but I've been unable to find an...

C++ Virtual Functions Question

Hey, so if I have a Base class and 2 derived classes... class Base { virtual void Output() { cout << "OUTPUTTING A BASE OBJECT" << endl; } }; class Derived : public Base { void Ouput() { cout << "OUTPUTTING A DERIVED" << endl; } }; class OtherDerived : public Base { }; As I understand it, if I try to call O...