virtual

Should I make my ASP.NET MVC controller actions virtual?

江枫思渺然 提交于 2019-12-01 04:06:10
File -> New Project for ASP.NET MVC projects used to generate controllers with virtual actions. I'm not sure if that stopped with MVC 2 or MVC 3, but is this no longer a best practice? archil T4MVC Does make action methods virtual. If you are using it, it should make action methods virtual, no other way it can work The current documentation for ASP.NET MVC 3 does not show virtual methods. I'm not really sure what making them virtual would gain you, as I've never subclassed controllers to override actions. If you make them virtual then it will make the controllers easier to mock if you are

How to find with javascript if element exists in DOM or it's virtual (has been just created by createElement)

谁说胖子不能爱 提交于 2019-12-01 03:57:46
I'm looking for a way to find if element referenced in javascript has been inserted in the document. Lets illustrate a case with following code: var elem = document.createElement('div'); // Element has not been inserted in the document, i.e. not present document.getElementByTagName('body')[0].appendChild(elem); // Element can now be found in the DOM tree Jquery has :visible selector, but it won't give accurate result when I need to find that invisible element has been placed somewhere in the document. Here's an easier method that uses the standard Node.contains DOM API to check in an element

Pure Virtual Class and Collections (vector?)

社会主义新天地 提交于 2019-12-01 03:48:18
I'm working on a graphics application that is using virtual classes fairly extensively. It has: A picture class, which is essentially a collection of shapes. A shapes class, which is purely virtual and has a few classes that inherit from it: Circle Polygon Rectangle A Figure shape, which is any graphical figure (also virtual), shape inherits from this. Essentially, my problem comes down to implementing the picture class, which is basically being used to store a collection of shapes. I'm currently using a Vector to store shapes, however, it's apparent that this is the wrong decision since

Overloading a virtual function in a child class

风格不统一 提交于 2019-12-01 03:30:17
I am just testing with virtual keyword and inheritance concepts in c++. I have written a small program: #include<stdio.h> #include<iostream> using namespace std; class cna_MO { public: virtual void print() { cout << "cna_MO" << endl; } }; class cna_bsc:public cna_MO { public: void print() { cna_MO::print(); } void print(int a) { cout << "cna_BSC" << endl; } }; class cna_Mo { cna_MO *_mo; public: cna_Mo() { _mo = new cna_bsc; } virtual void print(int a) { cout << "cna_Mo with arg" << endl; _mo->print(5); } virtual void print() { cout << "cna_Mo" << endl; _mo->print(); } }; int main() { cna_Mo

Is there any sense in marking a base class function as both virtual and final? [duplicate]

喜欢而已 提交于 2019-12-01 03:27:26
This question already has an answer here: What's the point of a final virtual function? 10 answers In various explanations of C++11's final keyword, I'm seeing examples like this. class base { public: virtual void f() final; }; class derived : public base { public: virtual void f(); // Illegal due to base::f() declared final. }; Is this actually a useful use of final ? Why would you declare a virtual function in a base class (implying that it will be usefully overrideable in derived classes) and then immediately mark it as final (negating that implication)? What is the utility of virtual void

“As a rule of thumb, make all your methods virtual” in C++ - sound advice?

别等时光非礼了梦想. 提交于 2019-12-01 03:04:36
I just happened upon the statement in the title. The full quote is: As a rule of thumb, make all your methods virtual (including the destructor, but not constructors) to avoid problems associated with omission of the virtual keyword. I found this in the Wrox book Professional C++ . You can google it to check. Is there anything to it? I would have thought that you'd only provide select extension points, not by-default extensibility. For instance, a 2001 article by Herb Sutter says so . Has anything changed dramatically since then to make the opposite the ruling norm? (Note that I'm a C++ noob

Capturing virtual screen (all monitors)

巧了我就是萌 提交于 2019-12-01 03:01:32
问题 I am trying to get a screenshot of the whole virtual screen. This means, an image of not just the primary screen, but every screen connected to the computer. Is there a way to do that? I tried using this, but it didn't work: Bitmap b = new Bitmap(SystemInformation.VirtualScreen.Width, SystemInformation.VirtualScreen.Height); Graphics g = Graphics.FromImage(b); this.Size = new Size(SystemInformation.VirtualScreen.Width, SystemInformation.VirtualScreen.Height); g.CopyFromScreen(0, 0, 0, 0, b

Multiple inheritance and pure virtual functions

百般思念 提交于 2019-12-01 02:29:06
The following code: struct interface_base { virtual void foo() = 0; }; struct interface : public interface_base { virtual void bar() = 0; }; struct implementation_base : public interface_base { void foo(); }; struct implementation : public implementation_base, public interface { void bar(); }; int main() { implementation x; } fails to compile with the following errors: test.cpp: In function 'int main()': test.cpp:23:20: error: cannot declare variable 'x' to be of abstract type 'implementation' test.cpp:16:8: note: because the following virtual functions are pure within 'implementation': test

Virtual function implemented in base class not being found by compiler

我与影子孤独终老i 提交于 2019-12-01 02:27:29
I've got a situation where it seems like the compiler isn't finding the base class definition/implementation of a virtual function with the same name as another member function. struct One {}; struct Two {}; struct Base { virtual void func( One & ); virtual void func( Two & ) = 0; }; struct Derived : public Base { virtual void func( Two & ); }; void Base::func( One & ) {} void Derived::func( Two & ) {} // elsewhere void this_fails_to_compile() { One one; Derived d; d.func( one ); } I'm using Visual C++ 2008. The error message is: error C2664: 'Derived::func' : cannot convert parameter 1 from

Should I make my ASP.NET MVC controller actions virtual?

主宰稳场 提交于 2019-12-01 01:44:36
问题 File -> New Project for ASP.NET MVC projects used to generate controllers with virtual actions. I'm not sure if that stopped with MVC 2 or MVC 3, but is this no longer a best practice? 回答1: T4MVC Does make action methods virtual. If you are using it, it should make action methods virtual, no other way it can work 回答2: The current documentation for ASP.NET MVC 3 does not show virtual methods. I'm not really sure what making them virtual would gain you, as I've never subclassed controllers to