parameter-passing

C++ template error

岁酱吖の 提交于 2019-12-06 04:53:19
I am learning C++ template, and I write a little algorithm. Unfortunately I got some errors Here is my code #include <iostream> #include <iomanip> #include <deque> using namespace std; template<typename T, typename S, typename W> void push(const T& value, deque<S>& original_stack, deque<W>& min_index) { original_stack.push_back(value); if (min_index.size() == 0) min_index.push_back(0); else { if (value < original_stack[min_index.back()]) { min_index.push_back(original_stack.size() - 1); } else { min_index.push_back(min_index.back()); } } } template<typename S, typename W> void pop(deque<S>&

Does inout/var parameter make any difference with reference type?

一个人想着一个人 提交于 2019-12-06 03:59:30
问题 I know what inout does for value types . With objects or any other reference type , is there a purpose for that keyword in that case, instead of using var ? Code example: private class MyClass { private var testInt = 1 } private func testParameterObject(var testClass: MyClass) { testClass.testInt++ } private var testClass: MyClass = MyClass() testParameterObject(testClass) testClass.testInt // output ~> 2 private func testInoutParameterObject(inout testClass: MyClass) { testClass.testInt++ }

how to make copy of array instead of reference in java? [duplicate]

随声附和 提交于 2019-12-06 03:20:15
This question already has answers here : How do I do a deep copy of a 2d array in Java? (6 answers) Closed 6 years ago . I want to make an exact copy of given array to some other array but such that even though I change the value of any in the new array it does not change the value in the original array. I tried the following code but after the third line both the array changes and attains the same value. int [][]a = new int[][]{{1,2},{3,4},{5,6}}; int[][] b = a; b[1][0] = 7; instead of the second line I also tried int[][] b = (int[][])a.clone(); int [][] b = new int [3][2]; System.arraycopy(a

xargs just working with built in functions

邮差的信 提交于 2019-12-06 00:05:57
I am trying to speed up the processing of a database. I migrated towards xargs. But I'm seriously stuck. Piping a list of arguments to xargs does not work if the command invoked by xargs isn't a built in. I can't figure out why. Here is my code: #!/bin/bash list='foo bar' test(){ echo "$1" } echo "$list" | tr '\012' '\000' | xargs -0 -n1 -I '{}' 'test' {} So there is no output at all. And test function never gets executed. But if I replace "test" in the "xargs" command with "echo" or "printf" it works fine. xargs takes an executable as an argument (including custom scripts) rather than a

Pass a C# Class Object to a Python file

核能气质少年 提交于 2019-12-05 23:33:27
Okay... I'm trying to pass an Object which I declare in C# to a Python file with IronPython. So this is what I was thinking off: C# class: public class ParamObj { private string Obj_String; private int Obj_Int; public ParamObj(string lObjS, string lObjI) { Obj_String = lObjS; Obj_Int = lObjI; } public string getString() { return Obj_String; } public int getInt() { return Obj_Int; } public setString(string lStr) { Obj_String = lStr; } public setInt(int lInt) { Obj_Int = lInt; } } So i have my Class.. Now i declare the Class in my C# Project and i pass it to the PYthon file: ParamObj Test_Object

How to return large data efficiently in C++11

こ雲淡風輕ζ 提交于 2019-12-05 22:46:20
I'm realy confused about returning large data in C++11. What is the most efficient way? Here is my related function: void numericMethod1(vector<double>& solution, const double input); void numericMethod2(pair<vector<double>,vector<double>>& solution1, vector<double>& solution2, const double input1, const double input2); and here is the way i use them: int main() { // apply numericMethod1 double input = 0; vector<double> solution; numericMethod1(solution, input); // apply numericMethod2 double input1 = 1; double input2 = 2; pair<vector<double>,vector<double>> solution1; vector<double> solution2

Define/Instantiate a java object from c/c++

牧云@^-^@ 提交于 2019-12-05 21:29:11
I a code in java that looks like the following: class MyClass { public void MyFunc(ISomeListener listener); } I want to call this method from a c++ program and pass to it the required parameter. Note that the parameter is an implementation of an interface. Thus I need to define AND create java object from c++ and pass it to the method. How can I do this? P.S. If it helps, the original problem is that the java program is an interface to a hardware (like a driver). I'm trying to create a DLL from this java code so that it can be used in any language. So I thought I'd wrap the code using C/C++

Angular2: ng-content attributes passing to child component

我们两清 提交于 2019-12-05 20:03:01
问题 Is something like this possible? I want to pass an "hasfocus" variable from cjc-box through ng-content attributes to the cjc-input component. app.component.html <div cjc-box><div cjc-input></div></div> cic-box.component.html <div class="cjc-box"> <div><ng-content hasfocus="focus"></ng-content></div> </div> cic-input.component.html <input class="cjc-input" type="text" focus="{{hasfocus}}" /> Is this even possible with projections in ng2? 回答1: It is possible to pass variable to projected

Parameter error when running selenium webdriver test case in Java

Deadly 提交于 2019-12-05 19:42:15
I'm trying to run this method in Selenium webdriver but I continue to get this error: org.testng.TestNGException: Method PopulateBorrower requires 2 parameters but 0 were supplied in the @Test annotation. at org.testng.internal.Parameters.checkParameterTypes(Parameters.java:198) at org.testng.internal.Parameters.createParameters(Parameters.java:134) at org.testng.internal.Parameters.createParameters(Parameters.java:370) at org.testng.internal.Parameters.handleParameters(Parameters.java:447) at org.testng.internal.Invoker.handleParameters(Invoker.java:1384) at org.testng.internal.Invoker

Spring 3 — form with 2 buttons, sending 2 parameters to controller method

倖福魔咒の 提交于 2019-12-05 19:00:43
问题 I have a Spring 3 MVC form with 2 parameters I'm trying to send to my controller method, and I'm getting a 404 error. The twist on this problem is that the form has 2 submit buttons, and the submit button that is clicked dictates the value of one of the parameters. Here is my form. <form:form action="/approve/${bulletin.id}" method="post"> <table> <tr> <td colspan="2"><b>From:</b> <c:out value="${bulletin.name}" /></td> </tr> <tr> <td colspan="2"><b>Subject:</b> <c:out value="${bulletin