virtual

Override contra-variance workaround needed

随声附和 提交于 2020-01-03 16:52:26
问题 I'm having difficulty finding the (what I'm sure is a very common) design pattern to work around the following problem. Consider this piece of code: class AA {}; class BB : public AA {}; class A { public: virtual void foo(AA& aa) = 0; }; class B : A { public: void foo(BB& bb){cout<<"B::foo"<<endl;} }; int main() { B b; BB bb; b.foo(bb); } This code will not compile because the class B does not override the pure virtual function 'foo'. The compiler considers the foo that B declares only as an

Override contra-variance workaround needed

生来就可爱ヽ(ⅴ<●) 提交于 2020-01-03 16:52:14
问题 I'm having difficulty finding the (what I'm sure is a very common) design pattern to work around the following problem. Consider this piece of code: class AA {}; class BB : public AA {}; class A { public: virtual void foo(AA& aa) = 0; }; class B : A { public: void foo(BB& bb){cout<<"B::foo"<<endl;} }; int main() { B b; BB bb; b.foo(bb); } This code will not compile because the class B does not override the pure virtual function 'foo'. The compiler considers the foo that B declares only as an

javafx programmatically set arguments for virtual keyboard

人走茶凉 提交于 2020-01-03 05:36:08
问题 I have a desktop application that will be used on computers with no keyboard, input will be on a touch screen. I can get the virtual keyboard to show up on textfields fine when running from eclipse. I used these arguments -Dcom.sun.javafx.touch=true -Dcom.sun.javafx.isEmbedded=true -Dcom.sun.javafx.virtualKeyboard=none The following link shows me where to add the arguments. how to add command line parameters when running java code in Eclipse? When I make a runnable jar file the keyboard does

virtual large data reading from log file into a ListView

冷暖自知 提交于 2020-01-03 04:47:06
问题 I've been doing some research on how to read large log files, ~500mbs and parse them into a gui using c#. I'm fairly new using virtual mode for listview... I've decided on using a listbox with virtual mode (hopefully this can handle about 1mil log messages). but I'm having problem reading the lines of the log file into the listbox. i don't want to read the whole file, because it would crash the program, so im using File.ReadLines in a foreach statement. I guess I'm having trouble handling the

Bypass virtual template functions to achieve wished result

╄→гoц情女王★ 提交于 2020-01-02 23:09:49
问题 My actual idea is not compiling due to C++ language limitation (templated virtual functions are not supported). Maybe some of you have some design recommendations for the following code snippet. I want to run different algorithms on different types of inputs. For example I have as input an integral image and an grayscale image. The integral image needs 32 bit for a pixel and my grayscale image needs 8 bit (just as an example). Therefore, I have two channels: CChannel<uint8> and CChannel

How to override a virtual function with a non-virtual function?

↘锁芯ラ 提交于 2020-01-02 06:58:35
问题 Refer to this question: Hide virtual function with non-virtual override And this question: override on non-virtual functions A function that overrides a virtual function is virtual too, even though it's not explicitly declared virtual. My technical question is: Is there away to make that overriding function non-virtual (and applies that to classes lower in the hierarchy)? In other words, can I turn the "virtuality" off? Obviously we can override a non-virtual function with a virtual function.

“Overloading” pure virtual function with different set of arguments

妖精的绣舞 提交于 2020-01-02 04:53:10
问题 Consider following code sample #include <iostream> using namespace std; class Color { public: virtual void mixColors(Color &anotherColor) = 0; }; class RGB : public Color { public: void mixColors(RGB &anotherColor); }; void RGB::mixColors(RGB &kol) { return RGB(0xABCDEF); } I perfectly know why this code is not working ( mixColors() in RGB is not implementing pure virtual function, because it has different set of arguments). However I would like to ask if is there another approach to solve

How to check if a property is virtual with reflection?

谁说胖子不能爱 提交于 2020-01-01 23:54:07
问题 Given an object, how can I tell if that object has virtual properties? var entity = repository.GetByID(entityId); I tried looking in: PropertyInfo[] properties = entity.GetType().GetProperties(); But couldn't discern if any of the properties would indicate virtual. 回答1: PropertyInfo[] properties = entity.GetType().GetProperties() .Where(p => p.GetMethod.IsVirtual).ToArray(); Or, for .NET 4 and below: PropertyInfo[] properties = entity.GetType().GetProperties() .Where(p => p.GetGetMethod()

How to be sure a method is overriding an existing virtual one in C++?

烈酒焚心 提交于 2020-01-01 18:57:08
问题 Let's suppose we have a base class which has a virtual method: class BaseClass { virtual void MethodToOverride() const { DoSomething(); } }; And a derived class which overrides the method (depending on the situation we can make it again virtual or not): class DerivedClass : public BaseClass { void MethodToOverride() const { DoSomethingElse(); } } If we make a mistake, for example defining the MethodToOverride non const or with a wrong character, we simply define a new method, for example:

Access Virtual Directory folder through code behind Asp.net

北城余情 提交于 2020-01-01 12:10:03
问题 I am trying to access a Virtual Directory folder from Code-behind. ASP.Net Website Name : SuperImages Physical folder : C:\images Virtual Directory folder : allimages (In same level as App_Data, Scripts, Properties folders) I am trying to access and do a count of the number of items in this folder, then display them on a webpage. How should I do this? Thanks in advance! ======================================================================= Update : From the posts below, it seems that Server