parameters

Pass variable from middleware to view via controller in Laravel 5.2

坚强是说给别人听的谎言 提交于 2020-01-14 02:59:13
问题 Hi I am trying to do the following in Laravel 5.2. Summary: Pass some variables from middleware to view, via controller Detailed: When a client is logged in, no matter what route they want, we need to check if they have completed all "setup steps" (each step refers to a different route, e.g. one could be company info, another could be product settings, etc). If they have completed all setup steps, then let them proceed to their chosen route, otherwise we redirect to the appropriate "setup

Function Parameter best practice

泪湿孤枕 提交于 2020-01-13 18:21:08
问题 I have question regarding the use of function parameters. In the past I have always written my code such that all information needed by a function is passed in as a parameter. I.e. global parameters are not used. However through looking over other peoples code, functions without parameters seem to be the norm. I should note that these are for private functions of a class and that the values that would have been passed in as paramaters are in fact private member variables for that class. This

C++ Style Convention: Parameter Names within Class Declaration

橙三吉。 提交于 2020-01-13 10:17:08
问题 I'm a fairly new C++ programmer and I would like to hear the arguments for and against naming parameters within the class declaration. Here's an example: Student.h #ifndef STUDENT_H_ #define STUDENT_H_ #include <string> using namespace std; class Student { private: string name; unsigned int age; float height, GPA; public: Student(string, unsigned int, float, float); void setAge(unsigned int); }; #endif /*STUDENT_H_*/ vs. #ifndef STUDENT_H_ #define STUDENT_H_ #include <string> class Student {

Using UNREFERENCED_PARAMETER macro

故事扮演 提交于 2020-01-13 08:47:31
问题 I'm using \W4 warning level on Visual Studio and I'm writing a Windows program. int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) All these parameters are not used in my application, so I get warnings at compile time. I know there are two ways of dealing with this: Commenting parameters HINSTANCE /*hInstance*/ ... Using the UNREFERENCED_PARAMETER macro int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)

Depending on a class template parameter, define or not define a function in the class

醉酒当歌 提交于 2020-01-13 08:39:22
问题 Suppose we have a class: template <class Type> class A { public: void function1(float a, Type b); void function1(float a, float b); }; Now instantiate the class like this: A<int> a; It's fine, this class will have 2 overloaded functions with these parameters: (float a, int b); (float a, float b); But when you instantiate the class like this: A<float> a; You get compile error: member function redeclared. So, depending on the type of Type, I wan't (or don't want) the compiler to define a

pass values from the view to the controller ruby on rails

余生长醉 提交于 2020-01-13 06:44:18
问题 This is my controller: def addcar @car = Car.new(params[:car]) render :action => "list" end this is my view: <%(@allcars).each do |cell|%> <p><%= link_to cell.to_s, :controller => "car", :action => "addcar", :car => cell.to_s %></p> <%end %> In the link_to statement I want to pass cell.to_s to the controller. How can I do that please? The cell.to_s is just a string but I want it to be the name of the car object ( car.Name ) 回答1: Car.new(params[:car]) expects params[:car] to be a Hash ( {:foo

How to pass a Class as Parameter

点点圈 提交于 2020-01-13 06:14:06
问题 In C++ is there a way to pass a type (e.g. a class) as parameter to a function? Explanation why I need this: There is a abstract data class and a manager class. The manager class contains a list (or in this case a map) of objects of derived classes of data . I use unique_ptr for this as mentioned in the answer of this question. class Data{}; // abstract class Manager { map<string, unique_ptr<Data>> List; }; Now imagine I want to add a new data storage to the manager. class Position : public

C# - Chain Calling of Constructor

痞子三分冷 提交于 2020-01-13 05:17:48
问题 I'm currently studying C# and I'm learning about constructors and the chain calling of constructors so as not to have to paste the same code (the same value for variables) in each constructor. I have three constructors, one with no parameters, one with three parameters and one with four parameters. What I'm looking to do is, use the default constructor to call the constructor with three parameters, passing default values for the parameters (variables) and the constructor that has three

How can I pass keyword arguments as parameters to a function?

梦想与她 提交于 2020-01-13 04:32:27
问题 Say I have a function defined thus: def inner_func(spam, eggs): # code I then want to call a function like this: outer_func(spam=45, eggs="blah") Inside outer_func I want to be able to call inner_func with exactly the same parameters that were passed into outer_func . This can be achieved by writing outer_func like this: def outer_func(spam, eggs): inner_func(spam, eggs) However, I'd like to be able to change the arguments inner_func takes, and change the parameters I pass to outer_func

Pentaho CDE reset parameter

十年热恋 提交于 2020-01-11 14:06:51
问题 I have a data table component and seven multiple selectors related to it. And i want to reset all selectors to default value with a reset button. My data source is SQL database, so i don't have a select "All" option in these selector. Is there any way to make it happen? 回答1: There are two issues you need to solve: Adding default values for the selectors Adding a button that resets these selectors to their default value For 1 I would go for something like this: Set the SQL query for the