virtual

Detect virtual keyboard vs. hardware keyboard

只愿长相守 提交于 2019-11-27 19:39:09
I have been thinking about this a while now, and I can't figure a way to deal with it. Is there any way to detect if the user uses a virtual (software) keyboard or a traditional (hardware) keyboard? The new Windows Surface has its own keyboard in the cover, and for Android / iPad there are a ton of different bluetooth keyboards. So, do any of you have any input about this? I'm aiming for Android, IOS & Windows Tablet/Phone. Motivation: (very subjective) When developing web applications for tablet/smartphone I have come to the understanding that it's easier - in many situations - to use a

translate virtual address to physical address

戏子无情 提交于 2019-11-27 19:31:07
The following page table is for a system with 16-bit virtual and physical addresses and with 4,096-byte pages. The reference bit is set to 1 when the page has been referenced. Periodically, a thread zeroes out all values of the reference bit.All numbers are provided in decimal. I want to convert the following virtual addresses (in hexadecimal) to the equivalent physical addresses. Also I want to set the reference bit for the appropriate entry in the page table. • 0xE12C • 0x3A9D • 0xA9D9 • 0x7001 • 0xACA1 I know the answers are but I want to know how can I achieve these answers: 0xE12C →

Alternative to c++ static virtual methods

只谈情不闲聊 提交于 2019-11-27 19:17:57
In C++ is not possible to declare a static virtual function, neither cast a non-static function to a C style function pointer. Now, I have a plain ol' C SDK that uses function pointers heavily. I have to fill a structure with several function pointers. I was planning to use an abstract class with a bunch of static pure virtual methods, and redefine them in derived classes and fill the structure with them. It wasn't until then that I realized that static virtual are not allowed in C++. Also this C SDKs function signature doesn't have a userData param. Is there any good alternative? The best I

c++ overloaded virtual function warning by clang?

六月ゝ 毕业季﹏ 提交于 2019-11-27 18:39:41
clang emits a warning when compiling the following code: struct Base { virtual void * get(char* e); // virtual void * get(char* e, int index); }; struct Derived: public Base { virtual void * get(char* e, int index); }; The warning is: warning: 'Derived::get' hides overloaded virtual function [-Woverloaded-virtual] (the said warning needs to be enabled of course). I don't understand why. Note that uncommenting the same declaration in Base shuts the warning up. My understanding is that since the two get() functions have different signatures, there can be no hiding. Is clang right? Why? Note this

Overriding vs Virtual

冷暖自知 提交于 2019-11-27 18:08:00
What is the purpose of using the reserved word virtual in front of functions? If I want a child class to override a parent function, I just declare the same function such as void draw(){} . class Parent { public: void say() { std::cout << "1"; } }; class Child : public Parent { public: void say() { std::cout << "2"; } }; int main() { Child* a = new Child(); a->say(); return 0; } The output is 2. So again, why would the reserved word virtual be necessary in the header of say() ? Thanks a bunch. krolth This is the classic question of how polymorphism works I think. The main idea is that you want

Override number of parameters of pure virtual functions

家住魔仙堡 提交于 2019-11-27 17:24:16
问题 I have implemented the following interface: template <typename T> class Variable { public: Variable (T v) : m_value (v) {} virtual void Callback () = 0; private: T m_value; }; A proper derived class would be defined like this: class Derived : public Variable<int> { public: Derived (int v) : Variable<int> (v) {} void Callback () {} }; However, I would like to derive classes where Callback accepts different parameters (eg: void Callback (int a, int b)) . Is there a way to do it? 回答1: This is a

Mongoose complex (async) virtuals

本秂侑毒 提交于 2019-11-27 15:14:07
I have two mongoose schemas as follow: var playerSchema = new mongoose.Schema({ name: String, team_id: mongoose.Schema.Types.ObjectId }); Players = mongoose.model('Players', playerSchema); var teamSchema = new mongoose.Schema({ name: String }); Teams = mongoose.model('Teams', teamSchema); When I query Teams I would to get also the virtual generated squad : Teams.find({}, function(err, teams) { JSON.stringify(teams); /* => [{ name: 'team-1', squad: [{ name: 'player-1' } , ...] }, ...] */ }); but I can't get this using virtuals , because I need an async call: teamSchema.virtual('squad').get

C++ virtual override functions with same name

末鹿安然 提交于 2019-11-27 15:00:47
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 specific function inline (i.e. not in the cpp file), but I suppose it's an extension. GCC complains about this. Is there a standard C++ way to tell the compiler which function I want to override? (visual c++ 2008) class Impl : public A , public B { public: void A::Function () { cout << "A::Function" <

Why is it allowed to call derived class' private virtual method via pointer of base class?

无人久伴 提交于 2019-11-27 14:49:48
问题 # include <iostream> using namespace std; class A { public: virtual void f() { cout << "A::f()" << endl; } }; class B:public A { private: virtual void f() { cout << "B::f()" << endl; } }; int main() { A *ptr = new B; ptr->f(); return 0; } This code works correctly and prints B::f(). I know how it works, but why is this code allowed? 回答1: Access control is performed at compile time, not runtime. There's no way in general for the call to f() to know the runtime type of the object pointed to by

C++ covariance in parameters

孤街浪徒 提交于 2019-11-27 14:40:18
I wanted to know why C++ does not support co-variance in parameters like in example below or if there is a way to achieve it? class base { public: virtual base* func(base * ptr) { return new base(); } }; class derived : public base { public: virtual derived* func(derived * ptr) override { return new derived(); } //not allowed }; The return type is permissible since derived inherits from base , but the function parameter can't work - not all base instances will be a derived also. What's supposed to happen in the cases where func is called on a pointer to base with a parameter that's not a