virtual

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

一曲冷凌霜 提交于 2019-12-04 17:01:43
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: void MethodToOverride() {} // I forgot the const void MthodToOverride() const {} // I made a typo So this

Delphi - convert physical path (device File handle) to virtual path

蓝咒 提交于 2019-12-04 14:50:39
How can I convert a path like \Device\HarddiskVolume3\Windows into its corresponding virtual path? (like c:\Windows in this case) Personally I prefer the native way: function GetHDDDevicesWithDOSPath:TStringlist; var i: integer; root: string; device: string; buffer: string; begin setlength(buffer, 1000); result:=TStringlist.create; for i := Ord('c') to Ord('z') do begin root := Char(i) + ':'; if (QueryDosDevice(PChar(root), pchar(buffer), 1000) <> 0) then begin device := pchar(buffer); result.add(format('%s = %s\',[device, root ])); end; end; end; NB : This code sample is taken from: http:/

父类子类指针相互转换问题

核能气质少年 提交于 2019-12-04 14:20:36
父类子类指针相互转换问题 1.当自己的类指针指向自己类的对象时,无论调用的是虚函数还是实函数,其调用的都是自己的: 2.当指向父类对象的父类指针被强制转换成子类指针时候,子类指针调用函数时,只有非重写函数是自己的,虚函数是父类的; 3.当指向子类对象的子类指针被强制转换成父类指针的时候,也就是父类指针指向子类对象,此时,父类指针调用的虚函数都是子类的,而非虚函数都是自己的; 将上面三句话总结成一句话就是: 当父类子类有同名非虚函数的时候,调用的是转换后的指针类型的函数;               当父类子类有同名虚函数的时候呢,调用的是指针转换前指向的对象类型的函数。 详见以下代码: 1 #include <iostream> 2 using namespace std; 3 class Base { 4 public: 5 virtual void f() { cout << "Base::f" << endl; } 6 virtual void g() { cout << "Base::g" << endl; } 7 void h() { cout << "Base::h" << endl; } 8 9 }; 10 class Derived:public Base 11 { 12 public: 13 virtual void f(){cout<<"Derived::f"<

Windows Memory Mapped Files

旧街凉风 提交于 2019-12-04 12:08:50
问题 I am trying to investigate the behaviour of the Windows Kernel with respect to Memory Mapped Files / Virtual Memory. Specifically I am interested in determining how frequently the contents of a memory mapped file are flushed (by Windows) to disk and what criterion Windows uses for deciding it is time to do so. I have done a bit of research online and, apart from the MSDN which deals more with the 'hows and whys' rather than detailing the internal workings, there doesn't appear to be much

How to link “parallel” class hierarchy?

霸气de小男生 提交于 2019-12-04 10:59:27
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 TMenuItem then Result := TMenuItemFrobber.Create(TMenuItem(AComponent)) else Result := TDefaultFrobber

How can Meteor handle multiple Virtual Hosts?

泪湿孤枕 提交于 2019-12-04 10:58:04
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 DB, and then NGINX immediately knows about that Virtual Host without any further NGINX configuration.

c++: Does a vtable contains pointers to non-virtual functions?

早过忘川 提交于 2019-12-04 10:55:14
问题 vtable contains pointers to virtual functions of that class. Does it also contains pointers to non-virtual functions as well? Thx! 回答1: It's an implementation detail, but no. If an implementation put pointers to non-virtual functions into a vtable it couldn't use these pointers for making function calls because it would often cause incorrect non-virtual functions to be called. When a non-virtual function is called the implementation must use the static type of the object on which the function

Access Virtual Directory folder through code behind Asp.net

霸气de小男生 提交于 2019-12-04 10:50:04
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.MapPath would give me the correct physical path. However, it seems to me that I am getting the wrong

Virtual friend functions for a base class?

无人久伴 提交于 2019-12-04 09:21:30
问题 I'm in the proccess of learning the language and this is a noob doubt. Is it possible to use a virtual friend function? I don't know if it's possible, I didn't even test it but it could be useful in some situations. For example, for the overloaded operator<<(). DerivedClass dc; BaseClass &rbc = dc; cout << rbc; My guess is it's possible, but I'm not sure since a friend function is not implemented in the class design, and theoretically is not part of it (though in this example, conceptually it

how to hide the virtual keyboard

不羁的心 提交于 2019-12-04 09:20:09
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 specify to only accept numeric input Can you please give me a reasonable solution to simply not show the