virtual

Cant copy construction be done without creating an explicit function in the pure virtual base class?

落爺英雄遲暮 提交于 2019-12-06 09:22:31
My objective is to do a deep copy of a class, but a virtual class is causing trouble. #include<iostream> using namespace std; class Vir//pure virtual class { public: virtual void hi()=0; }; class Handler:public Vir { public: int i; Handler() {} Handler(int val):i(val) {} void hi() {cout<<"Value of i="<<i<<endl;} int getI() const {return i;} void setI(int j) {i=j;} }; class ControlPanel { public: Vir *v; ControlPanel(const ControlPanel& c)//copy constructor { v=new Handler; v->setI(c.getI()); } int getI()const {return v->getI();} void initialize() {v=new Handler(10);} void hi() {v->hi();}

“virtual” method's return type in objective-c

*爱你&永不变心* 提交于 2019-12-06 08:10:24
I have a class which is supposed to be abstract. In one of it's abstract methods the return type may be an instance of class1,class2 or class3, depending on the class that's implementing the method. I'm wondering how should I declare the method in the abstract class. I thought about using dynamic typing, but I want the return type to be restricted to one of the 3 classes, not every type, and in addition I'm not sure I can override it so that in the inheriting class the return type will not match the return type in the abstract class. I'd be glad if you could help me with this, Tnx! Take a look

how to hide the virtual keyboard

狂风中的少年 提交于 2019-12-06 06:13:04
问题 I don't want to show the virtual keyboard. I tried the below method but it doesn't make any difference. InputMethodManager imm = InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE); imm.hideSoftInputFromWindow(enter_count.getWindowToken(), 0); enter_count is my edit text I have tried reading up on the InputMethod Manager but can't follow it. I can set the input type of my edit text called enter_count as follows enter_count.setInputType( InputType.TYPE_NULL ); but then I can't

Inheritance of virtual member functions with the same name

ⅰ亾dé卋堺 提交于 2019-12-06 05:57:41
class A { A() {}; virtual ~A() {}; virtual void Start() {}; virtual void Start(float a) {}; }; class B : public A { }; class C : public A { virtual void Start(float a) {}; } ... B BObj; BObj.Start(); // -> fine, no complain from g++ ... ... C CObj; CObj.Start(); // -> not fine -> error: no matching function for call to ‘C::Start()’ ... I suspect that the problem comes from that both virtual functions have the same name, but different parameter signature. What I would like to know is that this is a g++-specific error message, how it is implemented the vtable, or it is an error based on the C++

How to link “parallel” class hierarchy?

我是研究僧i 提交于 2019-12-06 05:11:34
问题 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(AComponent: TComponent): IFrobber; begin if AComponent is TCustomAction then Result := TActionFrobber.Create(TCustomAction(AComponent)) else if AComponent is

C++ vtable resolving with virtual inheritance

余生长醉 提交于 2019-12-06 05:06:30
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 if the base class is blank - ie, its virtual functions are defined as: virtual void doStuff() = 0; Does this mean that the resolution is not necessary, because there's only one set of functions to pick from? Forgive me if this is an stupid question - as I said

Virtual assignment operator overloading- how the correct overloaded function is chosen?

a 夏天 提交于 2019-12-06 04:49:23
The following code (from C++ FAQs 24.11) is implementing virtual assignment operator overloading and overriding: #include <iostream> using namespace std; class B{ public: virtual ~B() throw(); virtual B& operator= (const B& b) throw(); }; B::~B() throw(){} B& B::operator= (const B& b) throw() { cout << "B::operator=(const B&)\n"; return *this; } class D : public B{ public: virtual D& operator= (const B& b) throw(); D& operator= (const D& d) throw(); }; D& D::operator= (const B& b) throw() {cout << "D::operator= (const B&)\n"; return *this;} D& D::operator= (const D& d) throw() {cout << "D:

How to create a virtual device in linux?

假装没事ソ 提交于 2019-12-06 04:39:10
问题 My question is pretty much the same as - How to create a virtual file? except I want to do it in Linux instead. I imagine what I need to do is create a virtual device and point the application logging to that device. I'd like to write the device in python or ruby or something else interpreted, if possible. 回答1: check out named pipes http://en.wikipedia.org/wiki/Named_pipe 回答2: Use mknod. You can create a socket file which your apps can write too. And your logging app would connect to the

A virtual display for ubuntu server

こ雲淡風輕ζ 提交于 2019-12-06 04:36:41
My question is: is there a way to set up a virtual display as default display on a linux server (so that all GUI application launched will be displayed on that display, if no counter indication is made)? I tried using this: xvfb-run java -jar autoclick.jar , which produces the following output : searching graphic devices is Headless:false screen N°1 width:1600 height:900 just 1 robot click: Magic button clicked ! and here's the autoclick code : System.out.println("searching graphic devices"); System.out.println("is Headless:"+GraphicsEnvironment.isHeadless()); GraphicsEnvironment ge =

How can Meteor handle multiple Virtual Hosts?

梦想与她 提交于 2019-12-06 04:14:25
问题 How can Meteor handle multiple Virtual Hosts? www.Some-Client-Domain.com --> www.Our-CName-URL.com --> Meteor app. We need the Meteor app to serve the same site/app but with data specific to the original URL requested (Some-Client-Domain.com). In our current prototype, we have NGINX in front of Rails, and there are a few different ways to do this, including wiring NGINX to the DB for definitions of the MANY Virtual Hosts. This works great, because if a new client signs up, we can update the