parameter-passing

passing vector to function c++

给你一囗甜甜゛ 提交于 2019-12-18 12:38:24
问题 I have a main.cpp test.h and test.cpp> I am trying to pass my vector through so i can use it in test.cpp but i keep getting errors. //file: main.cpp int main(){ vector <Item *> s; //loading my file and assign s[i]->name and s[i]-address tester(s); } //file: test.h #ifndef TEST_H #define TEST_H struct Item{ string name; string address; }; #endif //file: test.cpp int tester(Item *s[]){ for (i=0; i<s.sizeof();i++){ cout<< s[i]->name<<" "<< s[i]->address<<endl; } return 0; } ---------------errors

Why doesn't this work if in Ruby everything is an Object?

和自甴很熟 提交于 2019-12-18 11:38:11
问题 Considering that in the Ruby programming language everything is said to be an Object, I safely assumed that passing arguments to methods are done by reference . However this little example below puzzles me: $string = "String" def changer(s) s = 1 end changer($string) puts $string.class String => nil As you can see the original Object wasn't modified, I wish to know why , and also, how could I accomplish the desired behavior ie. Getting the method to actually change the object referenced by

Unquoted tokens in argument mode involving variable references and subexpressions: why are they sometimes split into multiple arguments?

感情迁移 提交于 2019-12-18 11:25:22
问题 Note: A summary of this question has since been posted at the PowerShell GitHub repository, since superseded by this more comprehensive issue. Arguments passed to a command in PowerShell are parsed in argument mode (as opposed to expression mode - see Get-Help about_Parsing). Conveniently, (double-)quoting arguments that do not contain whitespace or metacharacters is usually optional , even when these arguments involve variable references (e.g. $HOME\sub ) or subexpressions (e.g., version=$(

How do I pass a hash to a function in Perl?

前提是你 提交于 2019-12-18 10:48:10
问题 I have a function that takes a variable and an associative array, but I can't seem to get them to pass right. I think this has something to do with function declarations, however I can't figure out how they work in Perl. Is there a good reference for this and how do I accomplish what I need? I should add that it needs to be passed by reference. sub PrintAA { my $test = shift; my %aa = shift; print $test . "\n"; foreach (keys %aa) { print $_ . " : " . $aa{$_} . "\n"; $aa{$_} = $aa{$_} . "+"; }

Can parameters be constant?

ぃ、小莉子 提交于 2019-12-18 10:46:12
问题 I'm looking for the C# equivalent of Java's final . Does it exist? Does C# have anything like the following: public Foo(final int bar); In the above example, bar is a read only variable and cannot be changed by Foo() . Is there any way to do this in C#? For instance, maybe I have a long method that will be working with x , y , and z coordinates of some object (ints). I want to be absolutely certain that the function doesn't alter these values in any way, thereby corrupting the data. Thus, I

Pass image from java applet to html

走远了吗. 提交于 2019-12-18 09:27:04
问题 I am using a signed java applet to load an image from the filesystem of the user. Then I want to display this image in the website where the applet is running. I know how to communicate between applet and JavaScript, but I only used strings and numbers as parameter. How do I handle image objects and how do I display them on the website? If required I can convert the format in the applet to match the JavaScript. Edit: I passed the Image object from java to javascript with a call from JSObject.

Named Parameters solution in PHP 7+

蹲街弑〆低调 提交于 2019-12-18 08:57:44
问题 How can I implement the named argument feature in PHP 7+? The ideal syntax is: find($wildcard, relative = true, listIfEmpty = false) { ... } But there is no solution to do like that. In the answer, I implemented the shortest possible solution that supports: Refactoring Type Hints for the params and function result Reusable param set Typesafe params Default values for params Getter for each param ( no hard-coded string ) Very simple setter/getter that you need to change just one name for every

Can an Oracle stored procedure that has a nested table parameter be called from ODP.NET?

自闭症网瘾萝莉.ら 提交于 2019-12-18 07:05:04
问题 I've got a stored procedure that has a couple parameters that are nested tables. CREATE TYPE FOO_ARRAY AS TABLE OF NUMBER; CREATE TYPE BAR_ARRAY AS TABLE OF INTEGER; CREATE PROCEDURE Blah( iFoos IN FOO_ARRAY, iBars IN BAR_ARRAY, oResults OUT SOMECURSORTYPE ) AS BEGIN OPEN oResults FOR SELECT * FROM SomeTable T JOIN TABLE(iFoos) foos ON foos.column_value = T.foo JOIN TABLE(iBars) bars ON bars.column_value = T.bar; END Using ODP.NET (Oracle.DataAccess.dll), is there a way to call this stored

Parameter with '&' breaking $.ajax request

核能气质少年 提交于 2019-12-18 07:00:26
问题 I'm developing a Web App that uses JavaScript + JQuery on the client side and PHP on the server side. One of the strings I want to pass as parameter for an AJAX Request has a '&' in its content. For this reason, the string of the request is broken. The browser "thinks" that this parameters is over because there is a '&' on the string. var hasChar = "This is a string that has a & in the content."; var doesntHave = "This one does not contain."; var dataString = "first=" + hasChar + "&second=" +

Passing an internal procedure as argument

被刻印的时光 ゝ 提交于 2019-12-18 06:50:32
问题 I want to solve a differential equation lots of times for different parameters. It is more complicated than this, but for the sake of clarity let's say the ODE is y'(x) = (y+a)*x with y(0) = 0 and I want y(1) . I picked the dverk algorithm from netlib for solving the ODE and it expects the function on the right hand side to be of a certain form. Now what I did with the Intel Fortran compiler is the following (simplified): subroutine f(x,a,ans) implicite none double precision f,a,ans,y,tol,c